- Use a custom service name
- Include additional attributes
- Share items with other apps and extensions using an access group
- Share items with other devices through iCloud synchronization
- Restrict item accessibility based on device state
- Require Touch ID / Face ID to retrieve an item
When creating the SimpleKeychain instance, specify a service name under which to save items. By default the bundle identifier of your app is used.
let simpleKeychain = SimpleKeychain(service: "Auth0")
When creating the SimpleKeychain instance, specify additional attributes to be included in every query.
let attributes = [kSecUseDataProtectionKeychain as String: true]
let simpleKeychain = SimpleKeychain(attributes: attributes)
When creating the SimpleKeychain instance, specify the access group that the app may share entries with.
let simpleKeychain = SimpleKeychain(accessGroup: "ABCDEFGH.com.example.myaccessgroup")
Note
For more information on access group sharing, see Sharing Access to Keychain Items Among a Collection of Apps.
When creating the SimpleKeychain instance, set synchronizable
to true
to enable iCloud synchronization.
let simpleKeychain = SimpleKeychain(sychronizable: true)
Note
For more information on iCloud synchronization, check the kSecAttrSynchronizable documentation.
When creating the SimpleKeychain instance, specify a custom accesibility value to be used. The default value is .afterFirstUnlock
.
let simpleKeychain = SimpleKeychain(accessibility: .whenUnlocked)
Note
For more information on accessibility, see Restricting Keychain Item Accessibility.
When creating the SimpleKeychain instance, specify the access control flags to be used. You can also include an LAContext
instance with your Touch ID / Face ID configuration.
let context = LAContext()
context.touchIDAuthenticationAllowableReuseDuration = 10
let simpleKeychain = SimpleKeychain(accessControlFlags: .biometryCurrentSet,
context: context)
Note
For more information on access control, see Restricting Keychain Item Accessibility.