swift – Persistent Id for my machine in iOS which can with stand app uninstalls, manufacturing facility reset and jailbroken eventualities

0
3


I need to have a persistent id for every machine in ios irrespective of getting a number of units linked to single icloud <I would like a number of persistent id’s every for machine>. and that ought to stand up to app uninstalls, manufacturing facility reset and jailbroken eventualities

I attempted this beneath one by saving in keychain

import Basis
import KeychainSwift

/// The `PersistentID` class generates and shops a persistent ID that can be utilized to establish a tool.
class PersistentID {
    non-public let keychain = KeychainSwift()
    non-public let key = "persistentID"
    
    /// A novel identifier for the machine, that's generated utilizing a mixture of `identifierForVendor` and `UUID`.
    var id: String {
        get {
            if let worth = keychain.get(key) {
                return worth
            } else {
                let newValue = UIDevice.present.identifierForVendor!.uuidString + UUID().uuidString
                keychain.set(newValue, forKey: key)
                return newValue
            }
        }
    }
    
    /**
    Initializes an occasion of `PersistentID`.
    */
    init() {}
}

LEAVE A REPLY

Please enter your comment!
Please enter your name here