Reputation: 169
I am trying to uniquely identify the iPhone/iPad mobile devices to save user data.
I found out some, including
[NSString *UUID = [[NSUUID UUID] UUIDString];
[UIDevice currentDevice].identifierForVendor.UUIDString;
or take device token from
- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{ ... }
But the problem is that
Since app store rejects using uniqueIdentifer, my question here is: Is there any way we can uniquely identify devices across any application updates, deletion, reinstallation?
Upvotes: 2
Views: 2354
Reputation: 4884
There's a great posting about this.
http://www.doubleencore.com/2013/04/unique-identifiers/
Upvotes: 1
Reputation: 69027
The closest thing I can think of is generating your own UUID and storing it in the device keychain.
By doing this, it will survive app deletion/reinstall, and if the user has enabled iCloud Keychain, it should also survive a device restore.
To make things easier, you can use a keychain wrapper among the many available as open source (one is here).
Upvotes: 1
Reputation: 2299
Use SSkeychain to store unique key permanently. Take 4 files from sskeychain folder from this github example into your project
then after use this code to get unique identifier.
-(NSString *)getUniqueDeviceIdentifierAsString
{
NSString *appName=[[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString*)kCFBundleNameKey];
NSString *strApplicationUUID = [SSKeychain passwordForService:appName account:@"incoding"];
if (strApplicationUUID == nil)
{
strApplicationUUID = [[[UIDevice currentDevice] identifierForVendor] UUIDString];
[SSKeychain setPassword:strApplicationUUID forService:appName account:@"incoding"];
}
return strApplicationUUID;
}
This identifier will not change after deleting and reinstalling app. I have used this and it is working perfect for me.
Upvotes: 2
Reputation: 80265
One creative method might be the possibility of (ab)using the MAC address of the wifi port.
Upvotes: 0