This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func setPassword(serivce: String, account: String, password: Data) { | |
| // 1. the query dictionary | |
| let query: [String: Any] = [ | |
| kSecClass as String: kSecClassGenericPassword, | |
| kSecAttrService as String: service, | |
| kSecAttrAccount as String: account, | |
| kSecValueData as String: password | |
| ] | |
| // 2. The function that actually store the value |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func delete(service: String, account: String) throws { | |
| // 1. create the query dictionary | |
| let query: [String: Any] = [ | |
| kSecClass as String: kSecClassGenericPassword, | |
| kSecAttrService as String: service, | |
| kSecAttrAccount as String: account | |
| ] | |
| // 2. delete the item | |
| let result = SecItemDelete(query as CFDictionary) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func update(service: String, account: String, password: Data) { | |
| let query: [String: Any] = [ | |
| kSecClass as String: kSecClassGenericPassword, | |
| kSecAttrService as String: service, | |
| kSecAttrAccount as String: account | |
| kSecValueData as String: password, | |
| ] | |
| let status = SecItemUpdate(query as CFDictionary, nil) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func get(service: String, account: String) -> Data? { | |
| // 1. create the query dictionary | |
| let query: [String: Any] = [ | |
| kSecClass as String: kSecClassGenericPassword, | |
| kSecAttrService as String: service, | |
| kSecAttrAccount as String: account, | |
| kSecReturnData as String: true | |
| ] | |
| // 2. create a variable to hold the result of the query |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func update(service: String, account: String, type: Int, password: Data) { | |
| let query: [String: Any] = [ | |
| kSecClass as String: kSecClassGenericPassword, | |
| kSecAttrService as String: service, | |
| kSecAttrAccount as String: account | |
| kSecValueData as String: password, | |
| kSecAttrType as String: type | |
| ] | |
| let status = SecItemUpdate(query as CFDictionary, nil) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func update(service: String, account: String, label: String, password: Data) { | |
| let query: [String: Any] = [ | |
| kSecClass as String: kSecClassGenericPassword, | |
| kSecAttrService as String: service, | |
| kSecAttrAccount as String: account | |
| kSecValueData as String: password, | |
| kSecAttrLabel as String: label | |
| ] | |
| let status = SecItemUpdate(query as CFDictionary, nil) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func createQuery(for serivce: String) -> [String: Any] { | |
| let query: [String: Any] = [ | |
| kSecClass as String: kSecClassGenericPassword, | |
| kSecAttrService as String: service, | |
| kSecReturnData as String: true, | |
| kSecMatchLimit as String: kSecMatchLimitAll | |
| ] | |
| return query | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| extension CFArray { | |
| var toSwiftArray: [Data] { | |
| let array = Array<AnyObject>(_immutableCocoaArray: self) | |
| return array.compactMap { $0 as? Data} | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func createQuery(for serivce: String) -> [String: Any] { | |
| let query: [String: Any] = [ | |
| kSecClass as String: kSecClassGenericPassword, | |
| kSecAttrService as String: service, | |
| kSecReturnAttributes as String: true, | |
| kSecReturnData as String: true, | |
| kSecMatchLimit as String: kSecMatchLimitAll | |
| ] | |
| return query | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Main Logic | |
| struct ShowExposureNotification { | |
| func sideEffect() { | |
| // navigate | |
| Utils.Show( | |
| "Screen.onboardingStep", | |
| context: "exposureNotificationPermissions" | |
| ) |