Allow developer to retrieve iOS's identifierForVendor as UUID for React Native Application.
Sometimes we need an unique identifier (e.g., when implementing special authentication flow) to identify an "user-device" pair. However, device token, which is mainly used for push notification, is not suitable in such use case. The reason is that device token can and will change. For details, please refers to Is the device token as unique as the device ID?.
Note: The UUID will change if the app is reinstalled
"The value in this property remains the same while the app (or another app from the same vendor) is installed on the iOS device. The value changes when the user deletes all of that vendor’s apps from the device and subsequently reinstalls one or more of them. The value can also change when installing test builds using Xcode or when installing an app on a device using ad-hoc distribution. Therefore, if your app stores the value of this property anywhere, you should gracefully handle situations where the identifier changes." - source: identifierForVendor
npm install --save react-native-device-uuidreact-native link
var DeviceUUID = ;DeviceUUID;
- In XCode, in the project navigator, right click Libraries
- Add Files to [your project's name]
- Go to node_modules
- react-native-device-uuid and add the .xcodeproj file
- In XCode, in the project navigator, select your project
- Add the lib*.a from the react-native-device-uuid project to your project's Build Phases - Link Binary With Libraries. Select the .a file.
- Go to the Build Settings tab.
- Make sure 'All' is toggled on (instead of 'Basic').
- Look for Header Search Paths and make sure it contains both
$(SRCROOT)/../../React- mark both as recursive.