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


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

I attempted this under 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 singular identifier for the machine, that's generated utilizing a mix 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() {}
}

See also  reactjs - Why does the enter field preserve glitching on iOS however not on Android?

Leave a Reply