I have react native app with the android device setup library implemented. I am able to setup a photon but i am having difficultly getting the device id once setup is complete. Does anyone have an idea on how to get the device id in a react native app once device setup is complete?
I wouldn’t recommend using React Native at all for anything ever. It was a mistake that many companies have retreated from, due to surprising and growing complexity as well as poor performance. Basically, you pay more to get less.
But if you must use RN for the setup process, you can use the native Android Setup library, and pass the result back through React Native bridges (https://facebook.github.io/react-native/docs/native-modules-android). Or, you may try using the JS setup library (https://github.com/particle-iot/softap-setup-js#example) from React Native, and get the device-id that way. From what I’ve heard, Flutter seems like a much more performant mutliplatform technology, but your app size will still be bigger than a native app. This is also an issue for React Native. If you have the option though, I’d go full native.
I can’t help with React Native specifically, but what you’ll need to research is how to receive Android “broadcasts”/“broadcast intents”.
I recommend starting a separate toy project to play around with sending & receiving broadcasts using React Native (I assume they must have some mechanism for doing this on Android), and once you’ve got that figured out, then come back to trying to receive the ID for device setup.
@jensck_particle actually, I was trying to get the device id after setting up with WiFi only, and the broadcast receiver fails every time. The intent it receives just says that the setup failed, and doesn’t attach the device id as an extra. How do I get the device id after only a WiFi setup?
I am able to get the device id through the convenience wrapper ParticleDeviceSetupLibrary.DeviceSetupCompleteReceiver. However if i call
ParticleDeviceSetupLibrary.initWithSetupOnly(this.getApplicationContext()); it always fails and i don’t get the device id. I would like to use the sdk to just to apply wifi credentials.