Reputation: 3
These days I am working on an iPhone application when has the requirement to identify the iPhone device when the user install the application after uninstall the same application. I searched google and apple docs to solve this problem then came across the apple deprecated uncertain methods to get the device information which is unique throughout all iPhone devices.
I also came across to identifierForVendor and advertisingIdentifier. I have used the identifierForVendor but had not luck. I also read about advertisingIdentifier in apple docs but did not understand it.
So I need your expertise to solve this problem
Upvotes: 0
Views: 96
Reputation: 124997
The vendor identifier can change from one install to the next, and the advertising identifier can change even while the app remains installed. Neither of these will suit your purpose.
In most cases, you should identify the user rather than the device by asking them to register with your server somehow.
Upvotes: 0
Reputation: 3012
You can use the NSUUID Class to create a unique ID for that specific device. Reference for the Class is available here: https://developer.apple.com/library/ios/documentation/Foundation/Reference/NSUUID_Class/Reference/Reference.html#//apple_ref/doc/c_ref/NSUUID
You can persist this ID in the keychain for the app, so even the user reinstalls the app, the UUID is persisted. You could directly use the identifierForVendor
if that's easier for you and persist it in the Keychain, although I'm not sure if identifierForVendor
returns a new key on every session or install.
Reference for Keychain can be found here: https://developer.apple.com/library/mac/documentation/security/conceptual/keychainServConcepts/iPhoneTasks/iPhoneTasks.html
The Keychain Services' API is pretty verbose, so if you're not into that kind of a thing, you could check Github for various Open Source implementations of the same. I personally prefer UICKeychainStore.
Upvotes: 1