2

Is it safe to use a react-native-device-info unique ID? From what I can understand it will always remain unique for both iOS and android no matter how many times the app will be uninstalled.

If not kindly suggest what else we can use to uniquely identify the device since I want to make sure every user login with a separate device.

const uniqueId = DeviceInfo.getUniqueID();

// iOS: "FCDBD8EF-62FC-4ECB-B2F5-92C9E79AC7F9"
// Android: "dd96dec43fb81c97"

Notes

iOS: This is IDFV so it will change if all apps from the current apps vendor have been previously uninstalled. android: Prior to Oreo, this id (ANDROID_ID) will always be the same once you set up your phone.

devedv
  • 562
  • 2
  • 15
  • 45
  • Yes, device ID is unique to the device. But what is the `// Windows: ??` line about? – Tom Oakley Feb 26 '19 at 17:08
  • for windows phone it doesn't work. I only need it for iOS and android. So do you think I can use 'UniqueID'? – devedv Feb 26 '19 at 17:09
  • 1
    React Native doesn't support Windows Phone. In fact, Windows Phone at this point is a dead product. Why are you trying to build for it? – Tom Oakley Feb 26 '19 at 17:17
  • no, I'm not I just copied this from the documentation. I'm editing the post. Can you pls tell that if unique ID can be used? – devedv Feb 26 '19 at 17:18
  • UniqueID will be fine if you want to identify devices and have some sort of authorisation API to only allow users to use authorised devices. But this will only work on iOS and Android. If you want to build an app for Windows you can't use React Native, or this package (because react-native-device-info is built for React Native). – Tom Oakley Feb 26 '19 at 17:21
  • Sorry, I didn't realise the Windows line was in the docs for that package (I have no idea why it is). Also looking again, I'm not sure about Android (I'm an iOS/frontend dev). This might be helpful: https://developer.android.com/reference/android/provider/Settings.Secure.html#ANDROID_ID - there are also lots of other questions similar to this, look at the side bar on the right hand side of this question. – Tom Oakley Feb 26 '19 at 17:27

1 Answers1

2

I was doing SDK for analysts, which generates billions of events every day and I can find the following.

For iOS:
IDFV - changes after user re-install app(if user had only one your app).
I recommend to use next form: currentTimeInMilliseconds_IDFV and save this to KeyChain. KeyChain is updated only after user reset the device to the factory settings.

For Android:
Android don't have a cool version.
I recommend to use form: android.os.Build.SERIAL_Settings.Secure.ANDROID_ID.
Each argument aren't unique and one million devices have about 100 repeats.

But sorry, I don't have example for react native, if you need an example I can search later.

  • thank you. can you provide where it is told that ANDROID_ID repeats I can't find it in any official documentation? – devedv Feb 27 '19 at 08:27
  • Hii, I am facing the same issue, the device id gets changed when re-installing the ios app. I am trying to save it in the keychain but keychain data is again getting lost when re-installing the app. I am using the library react-native-keychain to save. Any help would be appreciated! – Avnish Choudhary Feb 15 '22 at 11:02