0

I want to generate a device specific random uuid which does not change even if the user uninstalls all my apps and reinstall unlike identifierforvendor. How can I achieve this is Swift

Moin Shirazi
  • 4,372
  • 2
  • 26
  • 38
Tamil
  • 1,173
  • 1
  • 13
  • 35

2 Answers2

2

You can use the following function for creating the UUID:

func getUniqueDeviceIdentifierAsString() -> String {
    var appName: String? = (Bundle.main.infoDictionary?[(kCFBundleNameKey as? String)] as? String)
    var strApplicationUUID: String = SSKeychain.password(forService: appName, account: "incoding")
    if strApplicationUUID == nil {
        strApplicationUUID = UIDevice.current.identifierForVendor.uuidString
        SSKeychain.setPassword(strApplicationUUID, forService: appName, account: "incoding")
    }
    return strApplicationUUID
}

reference :How to preserve identifierForVendor in ios after uninstalling ios app on device?

Community
  • 1
  • 1
Aashish1aug
  • 795
  • 1
  • 8
  • 22
0

You need to create random UUID and save it to keychain. Try below link

https://github.com/taka0125/TAKUUID

Jasmeet Kaur
  • 1,538
  • 14
  • 16