3

I was using Mac address for unique identification of the iOS device, but from iOS7 the system always returns 02:00:00:00:00:00 value. I had searched three options for the mentioned issue:

  1. Vendor identification
  2. Advertising identification
  3. Getting serial number using IOUnit framework

Since the IOUnitFramework is not approved by appstore, cant use it in my application. And the vendor identification and advertising identification return very long values.

Is there any other possible way to uniquely identify the ios device?

Thanks in advance

Storing a unique identifier in keychain is another option. But we can't access the keychain directly from our ios device.So is there any other alternative way for unique identification of the device?

Sonal0706
  • 290
  • 3
  • 15

5 Answers5

3

No, Apple does not allow you to uniquely identify devices any more. This has to do with the user privacy. Since you are not identifying the user but a device.

Also don't use the ASIdentifierManager for identifying device, Apple is now reject apps that use this to identify device. The ASIdentifierManager is only to be used for advertisement purposes.

The only option left is either the the [[UIDevice currentDevice] identifierForVendor] or save your own custom create ID to the keychain. Saving to your own create id to the keychain will make sure that if the user deletes the app en reinstalls it later you can still access this value.

rckoenes
  • 69,092
  • 8
  • 134
  • 166
  • Identifying the device and not the user is an obviously stupid idea, if you think about what happens when I sell a used phone. Now a totally different person has the device. And my new phone isn't identified because it's different. – gnasher729 Mar 04 '14 at 09:58
  • @gnasher729 Well when developers used the `UDID` this would happen a lot. The same goes for the Mac Address. – rckoenes Mar 04 '14 at 10:02
  • I am curious, since creating a unique id in the keychain would be equivalent of the old "uniqueIdentifier" method, which apple made private--- wouldn't they be likely to reject an app if they noticed that you are reinventing that strategy for uniquely identifying a device? – patrick Jan 12 '16 at 16:50
  • Well no, since you can identify the device does not mean any other developer can grab that same identifier. Apple removed the `[UIDevice uniqueIdentifier]` you could identify a device from multiple sources. Thus some one could abuse this, like advertisers could see what other apps your where running and how long you are using each app on your device. Ofcourse this is still partly possible with the `ASIdentifierManager` but the user has the option not to share the information. – rckoenes Jan 13 '16 at 07:58
1

You can use UDID of the device by which you can uniquely identify iPhone device

Create UIID from this method

- (NSString *)createUUID
{
  CFUUIDRef theUUID = CFUUIDCreate(NULL);
  CFStringRef string = CFUUIDCreateString(NULL, theUUID);
  CFRelease(theUUID);
  [[NSUserDefaults standardUserDefaults] setObject:(__bridge NSString *)string forKey:@"UUID"];
  [[NSUSerDefaults standardUserDefaults] synchronize];
  return (__bridge NSString *)string;
}

Use this where you need the device UDID

- (NSString*)UUID
{
    return [[NSUserDefaults standardUserDefaults] ObjectForKey:@"UUID"];
}
Gajendra Rawat
  • 3,673
  • 2
  • 19
  • 36
  • 2
    Be aware that if you do it this way the ID is delete along with the app. – rckoenes Mar 04 '14 at 09:39
  • @rckoenes Yes in that case he should use unique identifier according to your suggetion. if app deleted from iOS device or reinstalled. unique identifier will not removed from keychain access – Gajendra Rawat Mar 04 '14 at 09:50
1

You might check on this link and this link. It shows you multiple ways to identify your iOS device. They are a little outdated, but identifierForVendor and advertisingIdentifier still works.

Advertising identifier is mainly used for advertising purpose, but Apple is encouraging using this identifier for any needs.

advertisingIdentifier is part of the new AdSupport.framework. The ASIdentifierManager singleton exposes the method advertisingIdentifier and calling that returns an instance of the NSUUID class.

NSString *adId = [[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString];

Identifier for vendor also return an UUID string :

NSString *idfv = [[[UIDevice currentDevice] identifierForVendor] UUIDString];
Jissay
  • 550
  • 9
  • 28
  • 1
    While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. – Rick Hoving Mar 04 '14 at 09:56
  • You are right, i will care more, thanks for the advice! – Jissay Mar 04 '14 at 09:58
1

There are a lot of ways for to get an unique identifier. You can get identifierForVendor as some guys recommended you or create an UUID as mokujin recommended you. Even there are external sources libraries like SecureUDID, OpenUDID... but all these has the same problem, if you remove your app and reinstall, you will get different identifier.

I have been working in a big company where they used MDM (Mobile Iron) which give you the posibility of to get the real UDID. I think you are not using MDM in your project so I recommend you to use one of the choice recommended here for me and others users and save it in your keychain. After of this, you should to check if you have this value keep in your keychain, for using it, if not, you should to get it and keep it.

Don´t save it in your NSUserDefaults because if you delete your app, your info kept there will be deleted.

For use your keychain I recommend you to use this class from Apple KeychainItemWrapper

Fran Martin
  • 2,369
  • 22
  • 19
  • Storing a unique identifier in keychain is a good option. curently i will check the udid and add a specific identifier corresponding to it and add it to keychain. Before adding to keychain will crosscheck whether identifier to that spefic udid is already present or not. Now my query is, once i generate the build using this source code and deploy it on another device directly without using mac book.. i i mean install the app from itunes present in windows machine would the app be able to communicate with keychain access – Sonal0706 Mar 05 '14 at 08:39
  • There is a keychain private for your app, and a keychain shared between apps of the same teamID. This keychain is in your device, no confuse with keychain of your macbook – Fran Martin Mar 05 '14 at 08:44
  • ok. Then if i store specific values with respect to device identifier in keychain access and if the application is installed on another ios device, then the app would be able to retrieve the keychaindata previously stored? – Sonal0706 Mar 05 '14 at 09:23
  • Actually i dint understand the statement 'a keychain shared between apps of the same teamID'. I had one more query that if i submit the app to app store, then retrieving the keychaindata when the application was being developed would be almost impossible. So wanted to know is there any other alternative? – Sonal0706 Mar 05 '14 at 09:30
  • You should to get a value for your device when you run the app for first time. So if you install in diferents device your app, each device will have diferent indentifier. I imagine, you want to use this identifier for communicate with a server, so you will register this identifier in your server. You should to check if the identifier created in an app exists already. If exist you should to callback a message like "duplicate value" and your app should to create other identifier and send it again. But it´s for sure, you need to create a method for create an identifier, using external libraries.. – Fran Martin Mar 05 '14 at 09:33
  • .. or creating your own method, maybe a random number between 1000000000 and 99999999999 and to append the current date in miliseconds for example. This will create an identifier which will be used for identificate. You only need to check in your server if this identifier exist and if not exist, keep it. If exist, create other new. – Fran Martin Mar 05 '14 at 09:36
  • You can share info between your apps using keychain and group access. You can find how to do it here http://shaune.com.au/ios-keychain-sharing-data-between-apps/ – Fran Martin Mar 05 '14 at 09:38
1

Apple kills the way of tracking application, though we can track application using following ids

  1. Identifier for vendor
  2. NSUUID
  3. CFUUID

But this device ids will reset if you factory reset your phone.

You will get detail description over here unique device identification in iOS

Peter O.
  • 32,158
  • 14
  • 82
  • 96
Nik
  • 1,679
  • 1
  • 20
  • 36