How to identify iOS device uniquely instead of using UUID and UDID [duplicate]
Asked Answered
M

2

11

In my iOS app, I have to restrict the user to use iOS app per device. To do this I found a solution that we can use the UUID (Universally Unique Identifier) or UDID (Unique Device Identifier). But according to this answer I can't use UUID, because if app gets deleted or reinstalled UUID has been getting changed and I don't want this. Also Apple rejects apps if app uses UDID.

Is there any way to identify iOS device uniquely.

Moina answered 19/6, 2015 at 10:54 Comment(9)
You can't. Apple doesn't allow it for the sake of confidentiality. But you could use Keychain access to store some useful data. But check Apple guidelines.Sharrisharron
@Can ATAC, Thank you for your comment. I don't want store any data, actually I want some unique value from device. Is there any other method to do this?Moina
UUID is the way... and depends on your app design.Duleba
@SrinivasanN, Thank you for your comment. As I mentioned in question, UUID getting changed if app gets deleted or reinstalled.Moina
Do your app has a server database?..if so you can always send back the new UUID for that user?Duleba
You can bypass it but Apple won't let you identify the device physically. But as Srinivasan N said, logically, you can associate you user with its data through a backend server.Sharrisharron
Yes my app has server database. But in the first time if I used new generated UUID while logging and that stores in the backend. And next time if he deletes and reinstalls the app again, then UUID will get changed. It is difficult to identify new user or existing.Moina
So what do you plan to do when I sell my old iPhone and buy a new one? Trying to identify devices is just plain stupid.Retarder
@gnasher729, About your doubt "So what do you plan to do when I sell my old iPhone and buy a new one?", user has to contact administrator to reset his login credentials. and about this doubt "Trying to identify devices is just plain stupid", its requirement and already told in question as "I have to restrict the user to use iOS app per device."Moina
B
15

Apple has done away with the approach of UDIDs and will reject apps that use the same for unique device identification. Source: TNW

What you are looking for is Vendor ID

Brainy answered 19/6, 2015 at 11:41 Comment(7)
@Vijayts, Thanks for your answer. I have one more doubt as is there any possibility that two devices will have same VenderID. Any idea?Moina
@iOSDev There is no chance for two devices to have the same vendorID. Its is unique for every installation of the particular app group on your device. For example many apps under the same app vendor will have the same vendor ID on a device until all the apps of that vendor are uninstalled and again installed on that device. Only in that case the device will give you a new vendor ID for the same device for the same app group's app. Hence the name, VendorID.Brainy
@VijayTholpadi Are you sure it will be different on different devices? Though in the docs it says, "A different value is returned for apps on the same device that come from different vendors, and for apps on different devices regardless of vendor." Then vendorId is the solution. And if I want it different for each apps then we can make a hash with vendorId and bundle name. And vendorID don't get reset like advertisingId, right?Nagaland
@Nagaland Yes it will be different for different devices. Think of it as an ID for an installation of an app from an application group for a device. It will get reset incase you uninstall all the applications from that application group.Brainy
DeviceCheck is the new option to uniquely identify the device, check out my answer here: #24754037Daimon
what if I have 2 apps with different vendor. And I would like to check if the it's the same device?Westphal
@Westphal You could try using advertising ID but I advise you to read through its usage policy before doing so as there are use-case restrictions. Otherwise doing this is straightforward only if you are having enterprise distribution which would have MDM support to identify a device uniquely.Brainy
W
1

I'm using this library for my projects, and it's working like a charm, please try :

https://github.com/blackpixel/BPXLUUIDHandler

easy to use :

Import BPXLUUIDHandler.h Retrieve the UUID with

[BPXLUUIDHandler UUID]

Thats all...

Here is some info from project's github page :

As of iOS 5, Apple has deprecated the device unique identifier api and hasn’t provided a friendly Obj-C replacement, instead recommending CFUUIDCreate and NSUserDefaults.

CFUUIDCreate isn’t very complicated and neither is NSUserDefaults, but this solution fails in a few different ways:

  • It’s not a quick one-shot call to get the UUID; you have to write your own wrapper to make it friendly
  • It doesn’t persist; deleting the app blows away the UUID (can be persisted if stored in the keychain though)
  • There’s no way to share it between apps
Webb answered 19/6, 2015 at 11:23 Comment(4)
@iOSDev is it fix your problem?Webb
#gyer Thanks for your answer. But I am facing problem while using UUID. Do you have another way to solve.Moina
You're welcome @iOSDev. You wrote "I can't use UUID, because if app gets deleted or reinstalled UUID has been getting changed and I don't want this", but what I suggest (BPXLUUIDHandler) it's not changing when user re-install the app. That will change if they do a full restore, but for most users won’t change until they get a new device. Please read this : blackpixel.com/writing/2012/03/…Webb
The problem with saving UUID in keychain is that, two devices synced from iCloud get the same UUID, not it? Did you notice this issue?Nagaland

© 2022 - 2024 — McMap. All rights reserved.