0

The backend apis I am using take unique device identifier and generate responses. In the client side, I am generating UUID for this unique identifier since Apple does not allow getting IMEI. I am storing the UUID (UserDefaults storage) and fetching it every time an api call is to be made. Now, my problem is that if the user clears the app data, the stored UUID gets cleared and a new id has to be generated. However, with this new id, the user request becomes invalid. How can this issue be resolved? Is there some kind of id that remains constant for a single device (something like device id in android)?

Sujal
  • 1,447
  • 19
  • 34
  • seems duplicate question . please check this https://stackoverflow.com/a/47862814/2741603 – adarshaU Jan 02 '18 at 05:36
  • Hello @sujal , You can use advertisement id for identifying devices. Here below snippet of code : if ASIdentifierManager.shared().isAdvertisingTrackingEnabled { return ASIdentifierManager.shared().advertisingIdentifier.uuidString // Get and return IDFA } else { return UIDevice.current.identifierForVendor!.uuidString } – Jay Mehta Jan 02 '18 at 06:09

1 Answers1

1

you can use the keychain secure storage to store the UUID, This will keep persisted even if you uninstall and then install the app.

Here is the 3rd party library written in Swift which simplifies the use of keychain.

https://github.com/evgenyneu/keychain-swift

By @Anand (Pls see the first comment).

Keychain is the actually good choice for storing UUID of the app in a secure manner, that can be persisted even when the app is deleted and re-installed. But in case, if the user resets the device for clearing the app data, even the keychain data will be deleted.

Jhaliya - Praveen Sharma
  • 31,697
  • 9
  • 72
  • 76
  • 1
    Keychain is actually good choice for storing UUID of the app in secure manner, that can be persisted even when the app is deleted and re-installed. But in case, if the user resets the device for clearing the app data, even the keychain data will be deleted. Just for your thought!! – Anand Jan 02 '18 at 07:37
  • @Anand, Agree with you. – Jhaliya - Praveen Sharma Mar 09 '18 at 07:21