How do i get the device id after setup is complete on Android react native?

photon
Tags: #<Tag:0x00007fe226645900>

#1

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 am using the docs as reference https://docs.particle.io/reference/SDKs/android/#advanced just not sure how to implement this native code into a react native app.


#2

I still have not been able to figure this out. Anyone got any ideas?


#3

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.


#4

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.


#5

Thanks will definitely consider this approach.