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.

5
  • Please check below link stackoverflow.com/questions/25925481/… Commented Nov 4, 2019 at 5:48
  • @RonakAdeshara this will not work in case of re-install the app. Commented Nov 4, 2019 at 5: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. Commented Nov 4, 2019 at 5:52
  • 1
    Does this answer your question? How to get a unique device ID in Swift? Commented Nov 4, 2019 at 9:03
  • In addition to what @rmaddy said - if that would possible, you could sell your users data to other vendors. Commented Oct 11, 2020 at 20:00

3 Answers 3

5

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.

Sign up to request clarification or add additional context in comments.

Comments

2

You can use the following

let id = UIDevice.current.identifierForVendor?.uuidString 

1 Comment

This does not meet the requirements listed in the question.
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.

1 Comment

This technique is no longer working with iOS 10.3. Keychain data is deleted when the app is removed by the user.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.