ahmad rafiq
ahmad rafiq

Reputation: 1

How to "Uniquely Identify" iPhone device ? As UDID is deprecated and UUID changes after app re-installed for same Vendor?

I am building an iOS app, in which there is an option where user can give his feedback about the app. I want to know that if same user is using the app with different login accounts in the same device and submitting feedback.

But As UDID is deprecated or its privilege is gone, and UUID also changes for app re-installation of same vendor, So what is the best way to achieve uniqueness of an iPhone device.

I have also generated custom UUID and saved it to Keychain and fetching it, its working fine, but is it an optimised solution. ? I am using keychainWrapper class

private func generateUuid() -> String {
    let uuidRef: CFUUID = CFUUIDCreate(nil)
    let uuidStringRef: CFString = CFUUIDCreateString(nil, uuidRef)
    return uuidStringRef as String
}

private func identifyUniqueDevice() {

    let UNIQUE_KEY = "mySuperDuperUniqueId"
    let uniqueDeviceId: String? = KeychainWrapper.standard.string(forKey: UNIQUE_KEY)

    guard uniqueDeviceId != nil else {
        let uuid = generateUuid()
        let saveSuccessful: Bool = KeychainWrapper.standard.set(uuid, forKey: UNIQUE_KEY)
        if saveSuccessful {
            print(uniqueDeviceId)
        } else {
            fatalError("Unable to save uuid")
        }
        return
    }
}

Upvotes: 0

Views: 598

Answers (0)

Related Questions