- 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).
- 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).
- If you are looking for something else, I think it's not possible.