11

I’m writing an app in React-Native and need some help concerning identifying the device after reinstalling the application.

What I need:

  • Get a unique device ID for every device for both Android and iOS.
  • The same ID should be returned even if the user uninstalls the application and installs it again.

The closest to this I’ve come over is the getUniqueID() method in react-native-device-info. However, a different ID will be returned on iOS if the app is reinstalled since the returned value for this method is related to the vendor.

Have a great day!

MisseMask
  • 419
  • 1
  • 6
  • 18
  • were you able to find a solution for this? Is the advertising identifier IDFA persistant across installs? – Noitidart Oct 17 '17 at 06:07
  • Did you get the solution? – Vijay Sharma Apr 02 '18 at 07:33
  • Hello, unfortunately I haven't worked on this project. I'm however thinking about using the keychain somehow to store the identifierForVendor. Please reply here if you acquire any solution for this problem. – MisseMask Apr 03 '18 at 13:25

3 Answers3

4
  1. Well, if you need it due security purposes (e.g. so nobody is abusing your API or premium content), you are looking for Device Check / App Attestation for iOS and Google Safety Net for Android. By using these libs, you will get a unique device token (on iOS) or attestation (on Android).

When using iOS, you can take this token, and set up two bits on a server hosted directly in Apple by using your own server as a middle-man (as you should not do it directly, from the mobile app).

According to Apple: Apple records the bits for you and reports the bits back to you, but you’re responsible for keeping track of what the bits mean. You’re also responsible for determining when to reset the bits for a given device; for example, when a user sells the device to someone else

Similarly, with Android - you just send attestation from device to server where it will be validated.

To use mentioned libs in React Native, you can either install corresponding libs:

or if you are using Firebase libs (e.g. from rnfirebase.io), you can use AppCheck that uses SafetyNet and DeviceCheck / App Attestation underhood and comes also with easy server-side verification (also for non-Firebase resources).

  1. If you need a solution that is focused on pushing data from server to client, you are looking for a push notification token.

Libs:

As this token can change over time (by design), you should implement few services that support that / or potentially re-architect your app. Typically, tokens are stored under the user profile in your backend (or they are linked in some other way to the user that is using the device in the given time).

  1. If you are looking for something else, I think it's not possible.
Stefan Majiros
  • 444
  • 7
  • 11
1

Don't worry MisseMask, uniqueID's are always unique for your app bundle ID. There are two uniqueID's for each app.

That is one unique ID for debug version, and another one for release version. So please check your app by install it again and again with debug mode. now you get the same uniqueID. and do this process again with release build

for example:

Debug version uniqueID: 
  1st install  - 3279dhsbqd9yrbceqiqbcv
  2nd uninstall and install - 3279dhsbqd9yrbceqiqbcv
  3, 4, 5, 6, .... - are same uniqueID
Release version uniqueID:
  1st install - dsvfhdfgdf454tdsgsghetuh7j5
  2 nd uninstall and install - dsvfhdfgdf454tdsgsghetuh7j5
  3, 4, 5, 6, .... - are same uniqueID
Karthikeyan Ganesan
  • 1,901
  • 20
  • 23
0

if you need a unique identity for each device be sure to use IMEI you can fetech it by using

npm install react-native-imei --save

put this code when you fire your app

const IMEI = require('react-native-imei');
IMEI.getImei().then(imeiList => {
console.log(imeiList)
});

dont forget to put this in android AndroidManifest.xml

<uses-permission android:name="android.permission.READ_PHONE_STATE" />
Kero Fawzy
  • 690
  • 1
  • 7
  • 19