Expo Get Unique Device Id Without Ejecting
Solution 1:
For Expo IOS theres currently very limited options, Since Apple forbids getting private device info. We will need to create our own unique identifier below.
My solution is a combination of uuid and Expo SecureStore works for IOS and Android.
import * asSecureStorefrom'expo-secure-store';
import'react-native-get-random-values';
import { v4 as uuidv4 } from'uuid';
let uuid = uuidv4();
awaitSecureStore.setItemAsync('secure_deviceid', JSON.stringify(uuid));
let fetchUUID = awaitSecureStore.getItemAsync('secure_deviceid');
console.log(fetchUUID)
This solution will work even if app gets reinstalled, or if user switches devices and copy's all data to new device.
(Expo.Constants.deviceId
is deprecated and will be removed in SDK 44)
Solution 2:
Guess you can use facebook module for this purpose. https://docs.expo.io/versions/latest/sdk/facebook-ads/#currentdevicehash
Not sure what happens under hood - but looks like it unique between app reinstal, device restart etc.
Solution 3:
Just use getuniqueid() method from react-native-device-info. Works on iOS and android to uniquely identify a device .
Post a Comment for "Expo Get Unique Device Id Without Ejecting"