2

I have to integrate a system in which I have to enter the device UUID manually to register the device into my database. And at the time of login if the device UUID match with the database value, only then the user can able to access the application.

Now my problem is that when I am fetching the Device UUID using iTunes it comes different and Programeticaly fetched value is different.

I am using the below code.

UIDevice.current.identifierForVendor!.uuidString

please let me know what I am doing wrong.

UPDATE:- Please read the complete problem before down vote :(

Mohindra Bhati
  • 146
  • 1
  • 8
  • any other unique identifier also work for me – Mohindra Bhati Dec 12 '19 at 13:43
  • You could use something like: `let unique = NSUUID().uuidString` ? check `NSUUID` class for more. – Lucho Dec 12 '19 at 13:46
  • Thanks, @Lucho but my problem is still the same. The UUID gets updated every time but my device UUID from iTunes remains the same. – Mohindra Bhati Dec 12 '19 at 14:04
  • I see, you could store it on the KeyChain or user defaults? – Lucho Dec 12 '19 at 14:07
  • @Lucho in my app, I can store it but before installing the app into any device. I have to register that device into my DB Where I am using the UDID from iTunes. Because UDID of a device is never changed. But when I am trying to fetch the same programmatically it's got changed every time. – Mohindra Bhati Dec 12 '19 at 14:13
  • is Their any other id available which remains the same into the physical device and programmatically we can fetch it into our code. – Mohindra Bhati Dec 12 '19 at 14:15
  • You could add that iTunes ID to the app's plist file (you will have to do this for each install) and then read that value from within the app. Here is how to: https://stackoverflow.com/a/39453212/4905076 You could also add a config screen to your app where you add that ID and store it. – Lucho Dec 12 '19 at 14:23
  • https://stackoverflow.com/questions/58687743/swift-how-to-programmatically-get-the-unique-identifier-of-an-ios-device/59259936#59259936 – Rob Napier Dec 12 '19 at 15:15

1 Answers1

5

identifierForVendor is not the device UUID. You cannot programmatically access the device UUID. The only ID you are supposed to use to identify a device is identifierForVendor, which intentionally can change if the user uninstalls all of your apps. There is, intentionally, no fixed-to-the-device ID that you are permitted to access.

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