ArcGIS Runtime SDK for iOS: AGSKeychainItem Class Reference
ArcGIS Runtime SDK for iOS  100.15
AGSKeychainItem Class Reference

Description

A convenience class to store and retrieve objects in the keychain.

This class represents a generic keychain item which can store objects securely and retrieve them from the keychain. The object must implement NSCoding. For example, you can store an AGSCredential representing a user's identity and retrieve it when the app is restarted so that the user does not have to log in again.

@define{AGSKeychainItem, ArcGIS}

Since
100
Inheritance diagram for AGSKeychainItem:

Instance Methods

(instancetype) - initWithIdentifier:accessGroup:acrossDevices:
 
(instancetype) - initWithIdentifier:accessGroup:acrossDevices:accessible:
 
(nullable id< NSCoding >) - readObjectFromKeychain
 
(void) - removeObjectFromKeychainWithCompletion:
 
(void) - writeObjectToKeychain:completion:
 

Class Methods

(instancetype) + keychainItemWithIdentifier:accessGroup:acrossDevices:
 
(instancetype) + keychainItemWithIdentifier:accessGroup:acrossDevices:accessible:
 

Properties

NSString * accessGroup
 
NSString * identifier
 
BOOL sharedAcrossDevices
 

Method Documentation

◆ initWithIdentifier:accessGroup:acrossDevices:

- (instancetype) initWithIdentifier: (NSString *)  identifier
accessGroup: (nullable NSString *)  accessGroup
acrossDevices: (BOOL)  acrossDevices 

Initialize the keychain item with given identifier, access group and shared across devices.

Parameters
identifierMust be unique, for example - com.acme.appname
accessGroupIf you want the new keychain item to be shared among multiple applications, the value of this key must be the name of a keychain access group to which all of the programs that will share this item belong. Otherwise, nil.
acrossDevicesIf you want to share the keychain item across devices using iCloud Keychain then set to YES. The iCloud Keychain must be enabled on device to make this work.
Since
100

◆ initWithIdentifier:accessGroup:acrossDevices:accessible:

- (instancetype) initWithIdentifier: (NSString *)  identifier
accessGroup: (nullable NSString *)  accessGroup
acrossDevices: (BOOL)  acrossDevices
accessible: (AGSKeychainItemAccessible accessible 

Initialize the keychain item with given identifier, access group and shared across devices.

Parameters
identifierMust be unique, for example - com.acme.appname
accessGroupIf you want the new keychain item to be shared among multiple applications, the value of this key must be the name of a keychain access group to which all of the programs that will share this item belong. Otherwise, nil.
acrossDevicesIf you want to share the keychain item across devices using iCloud Keychain then set to YES. The iCloud Keychain must be enabled on device to make this work.
accessibleIndicates when a keychain item is accessible. If acrossDevices is YES, the valid options are only those which do not end with ThisDeviceOnly, as those cannot sync to another device. For macOS, this works only if acrossDevices is YES. You cannot change this option for an existing item. The keychain item will always be persisted with the option you first provided. To change this option, you first have to remove the existing keychain item using removeObjectFromKeychainWithCompletion:.
Since
100.2

◆ keychainItemWithIdentifier:accessGroup:acrossDevices:

+ (instancetype) keychainItemWithIdentifier: (NSString *)  identifier
accessGroup: (nullable NSString *)  accessGroup
acrossDevices: (BOOL)  acrossDevices 

Initialize the keychain item with given identifier, access group and shared across devices.

Parameters
identifierMust be unique, for example - com.acme.appname
accessGroupIf you want the new keychain item to be shared among multiple applications, the value of this key must be the name of a keychain access group to which all of the programs that will share this item belong. Otherwise, nil.
acrossDevicesIf you want to share the keychain item across devices using iCloud Keychain then set to YES. The iCloud Keychain must be enabled on device to make this work.
Since
100

◆ keychainItemWithIdentifier:accessGroup:acrossDevices:accessible:

+ (instancetype) keychainItemWithIdentifier: (NSString *)  identifier
accessGroup: (nullable NSString *)  accessGroup
acrossDevices: (BOOL)  acrossDevices
accessible: (AGSKeychainItemAccessible accessible 

Initialize the keychain item with given identifier, access group and shared across devices.

Parameters
identifierMust be unique, for example - com.acme.appname
accessGroupIf you want the new keychain item to be shared among multiple applications, the value of this key must be the name of a keychain access group to which all of the programs that will share this item belong. Otherwise, nil.
acrossDevicesIf you want to share the keychain item across devices using iCloud Keychain then set to YES. The iCloud Keychain must be enabled on device to make this work.
accessibleIndicates when a keychain item is accessible. If acrossDevices is YES, the valid options are only those which do not end with ThisDeviceOnly, as those cannot sync to another device. For macOS, this works only if acrossDevices is YES. You cannot change this option for an existing item. The keychain item will always be persisted with the option you first provided. To change this option, you first have to remove the existing keychain item using removeObjectFromKeychainWithCompletion:.
Since
100.2

◆ readObjectFromKeychain

- (nullable id<NSCoding>) readObjectFromKeychain

Retrieve the archivable object from the kSecValueData in the keychain item

Since
100

◆ removeObjectFromKeychainWithCompletion:

- (void) removeObjectFromKeychainWithCompletion: (nullable void(^)(NSError *__nullable error))  completion

Removes generic keychain item data.

Parameters
completionblock that is invoked when the operation completes. The error argument will be populated if a problem is encountered while removing the item from the keychain.
Since
100

◆ writeObjectToKeychain:completion:

- (void) writeObjectToKeychain: (id< NSCoding >)  object
completion: (nullable void(^)(NSError *__nullable error))  completion 

Set an archivable object as the kSecValueData in the keychain item.

Parameters
objectThe archivable object to store in the keychain.
completionblock that is invoked when the operation completes. The error argument will be populated if a problem is encountered while storing the item in the keychain.
Since
100

Property Documentation

◆ accessGroup

- (NSString*) accessGroup
readnonatomiccopy

Use keychain access group to share keychain item among multiple applications. It is used when synchronizing and persisting the cache with the keychain.

See also
#initWithIdentifier:accessGroup:acrossDevices:acrossDevices:
Since
100

◆ identifier

- (NSString*) identifier
readnonatomiccopy

The keychain identifier is used when synchronizing and persisting the cache with the keychain.

See also
- initWithIdentifier:accessGroup:acrossDevices:
Since
100

◆ sharedAcrossDevices

- (BOOL) sharedAcrossDevices
readnonatomicassign

Indicates whether keychain item is shared across devices using iCloud Keychain or not.

See also
#initWithIdentifier:accessGroup:acrossDevices:acrossDevices:
Since
100