2

I am using UUID to get Unique code from iOS Devices but while uninstalling or deleting and re-installing id Changed.. Suggest Without saving to Keychain and ASIdentifierManager.

let deviceId = (UIDevice.current.identifierForVendor?.uuidString)!

But in android - ANDROID_ID working fine

Note :Keeping the apple privacy and security

SANTOSH
  • 183
  • 1
  • 15
  • currently using for device = "ASIdentifierManager.shared().advertisingIdentifier" but is also changed when formatting the ios device or resetting ....please suggest – SANTOSH Nov 18 '19 at 06:23

3 Answers3

1

You can store UUID in SSKeychain which will be there forever. See the below code:

class func createUUID() -> String
{
    let appName = Bundle.main.infoDictionary![kCFBundleNameKey as String] as! String
    var strApplicationUUID = SSKeychain.password(forService: appName, account: "incoding")
    if strApplicationUUID == nil {
        strApplicationUUID = UIDevice.current.identifierForVendor!.uuidString
        SSKeychain.setPassword(strApplicationUUID, forService: appName, account: "incoding")
    }
    return strApplicationUUID!
}
PinkalB
  • 93
  • 6
0

when app is uninstall and install new app then you get unique code is different that also define in documentation of apple.

you may try

let UUID = NSUUID.UUID().UUIDString

for unique uuid Code.

Sagar Bhut
  • 657
  • 6
  • 28
0

Addition @sagar's answer which yes UUID is unique for app every install basis. but you may want to use UDID which unique for everydevice. You can check also this answer from another question. it explains better. It might help.

flyingBear
  • 487
  • 1
  • 6
  • 16