evgenyneu / keychain-swift

Helper functions for saving text in Keychain securely for iOS, OS X, tvOS and watchOS.
MIT License
2.82k stars 345 forks source link

Sometimes the value obtained changes #179

Open Serakaterina opened 8 months ago

Serakaterina commented 8 months ago
private static let keychain = KeychainSwift()

private static let KWNETWORKUUIDKEY = "kw_network_uuid_key"

static func idfv() -> String {
    semaphore.wait()
    var result = keychain.get(KWNETWORKUUIDKEY)
    var log = ""
    if result == nil {
        let temp = UIDevice.current.identifierForVendor?.uuidString
        result = temp
        if result != nil {
            let saveRes = keychain.set(result!, forKey: KWNETWORKUUIDKEY)
        }
    }
    if result == nil || result!.isEmpty {
        exit(0)
    }
    semaphore.signal()
    return result!
}

The value obtained through the “get value for key” method will change. Can anyone give me an answer?