0

I am creating an iOS app that I need a unique identifier that has to be the same even user removes all content(reset to factory settings).

I know years ago we can get the UDID but right now we can only create an UUID which changes every time user re-install the app or reset device to factory settings.

Zouhair Sassi
  • 1,403
  • 1
  • 13
  • 30
Yibin Feng
  • 63
  • 1
  • 1
  • 4
  • Please check below link https://stackoverflow.com/questions/25925481/how-to-get-a-unique-device-id-in-swift – Ronak Adeshara Nov 04 '19 at 05:48
  • @RonakAdeshara this will not work in case of re-install the app. – SGDev Nov 04 '19 at 05:50
  • 7
    Do not attempt to do this. There is a valid reason that Apple doesn't make this easy (if possible at all). Think about a user buying a used iOS device. Do you really want to treat that new person as if they were the previous owner? Respect privacy, don't work around it. – rmaddy Nov 04 '19 at 05:52
  • 1
    Does this answer your question? [How to get a unique device ID in Swift?](https://stackoverflow.com/questions/25925481/how-to-get-a-unique-device-id-in-swift) – Durdu Nov 04 '19 at 09:03
  • In addition to what @rmaddy said - if that would possible, you could sell your users data to other vendors. – user-123 Oct 11 '20 at 20:00

3 Answers3

3

This is intentionally impossible. You are not permitted to track the user this way. If you attempt to work around this restriction, Apple will likely break your technique in a future release (they've quietly broken several hacks people have used previously, generally without warning), and they may reject the app entirely.

The correct way to identify a device is with identifierForVendor. It is reset to a new value whenever the last of your apps is removed from the device and one of your apps is reinstalled. (By "your apps" I mean apps with the same start to their bundle id.) The fact that it can be reset is a system feature, and Apple does not allow you to circumvent it.

Rob Napier
  • 286,113
  • 34
  • 456
  • 610
1

You can use the following

let id = UIDevice.current.identifierForVendor?.uuidString

0

What I did was create a UUID string by NSUUID during the first time launch the app, and store this UUID string in the Keychain. Next time when you want to get an unique string, you can simply read this UUID string from Keychain. So this UUID can be treated as an UDID.

Kyle
  • 1
  • 1