MobileAccess
public protocol MobileAccess : AnyObject
Interface to the Gallagher mobile access SDK
-
Starts registration for a new Mobile Credential. Can be invoked from any thread Supply a
RegistrationDelegateto be notified about, and interact with the registration processNote: A fully qualified invitation URI looks like this: https://commandcentre-ap-southeast-2.security.gallagher.cloud/api/invitations/J7ZU-EJU4-RMCU-KNCU
If you do not have a fully qualified URI, and only have the unique code on the end, you can use
resolveInvitationUrito build a fully qualified URIDeclaration
Swift
func registerCredential(url: URL, delegate: RegistrationDelegate)Parameters
urlcredential registration URL
delegatea delegate that allows receiving callbacks on the registration process success/errors
-
Gets all registered Mobile Credentials Must be invoked on the main thread
Declaration
Swift
var mobileCredentials: [MobileCredential] { get } -
Gets all Mobile Credentials from the database, optionally filtering out revoked credentials Must be invoked on the main thread
Declaration
Swift
func getMobileCredentials(options: MobileCredentialFilter) -> [MobileCredential]Parameters
optionsWhether to filter out revoked credentials or include them
-
Gets a Mobile Credential by its identifier. Must be invoked on the main thread
Declaration
Swift
func getMobileCredential(credentialId: String) -> MobileCredential?Parameters
credentialIdcredential id of the credential to find
Return Value
the found credential or nil if no credential is found
-
Deletes a mobile credential. Can be invoked from any thread
The default behaviour is for the SDK to also contact the Gallagher Cloud, and delete the credential record from the cloud before removing the entry from the local SDK’s data store.
This means that if the internet connection is offline, the method will fail and the credential will not be deleted, which is the recommended behaviour. If you do really need to delete a credential from the local SDK while offline, you can supply
.allowOfflineor.offlineOnlyfor deleteOptionDeclaration
Swift
func deleteMobileCredential(_ mobileCredential: MobileCredential, deleteOption: DeleteOption, onCredentialDeleteCompleted: @escaping CredentialDeleteCompletedHandler)Parameters
mobileCredentialThe mobile credential to delete
deleteOptionAdvanced usage if you need to delete credentials while offline.
onCredentialDeleteCompletedCallback interface to notify about the result from the delete operation.
-
Starts or Stops scanning for readers. This will start/stop auto-connect attempts if the current SDK instance is configured to do automatic access attempts
Precondition
For the SDK to start scanning it requires- At least one credential registered.
- Passcode must be set.
- Bluetooth ON
You can call setScanning(true) at any point, and the SDK in the background will only start scanning once all preconditions are true.
Note: There is no
isScanningbecause the value of whether or not we are scanning depends on a variety of things and can change rapidly. If you want to track whether the SDK is currently scanning or not, please useaddSdkStateDelegateto provide a callback.Refer to
states:[MobileAccessState]for potential scanning problems and warningsCan be invoked from any thread
Declaration
Swift
func setScanning(enabled: Bool)Parameters
enabledIf true, will try and start scanning. If false, will stop scanning
-
Build a correct format for invitation URL used typically when manually registering Can be invoked from any thread
Declaration
Swift
func resolveInvitationUrl(_ rawUrl: String, invitation: String) -> URL?Parameters
rawUrlregion URL
invitationinvitation code
Return Value
formatted invitation URL that can be passed to register credential
-
Requests access via a particular reader and calls back to the appropriate functions on the specified delegate Can be invoked from any thread
Declaration
Swift
func requestAccess(reader: Reader, delegate: AccessDelegate)Parameters
readerThe reader to request access by
delegateThe delegate to callback on when access is granted, denied or a general error condition occurs.
-
Requests an action to a reader Can be invoked from any thread
Declaration
Swift
func requestReaderAction(reader: Reader, action: ReaderAction, onReaderActionCompleted: @escaping ReaderActionCompletedHandler)Parameters
readerThe reader to request action for
actionaction to perform
onReaderActionCompletedReturns
readerandactionof the request with `nil’ error if the request completed successfully. Otherwise, returns a non-nil error to indicate request failure -
Enumerates the list of reader actions Can be invoked from any thread
Declaration
Swift
func enumerateReaderActions(reader: Reader, onReaderActionEnumerationCompleted: @escaping ReaderActionEnumerationCompletedHandler)Parameters
readerThe reader to enumerate the actions for
onReaderActionEnumerationCompletedReturns the
readerand list of actions with `nil’ error if the enumerate completed successfully. Otherwise, returns a non-nil error to indicate request failure -
Add a delegate to listen to the state of the SDK. Warnings and errors will be announced via the handler provided Can be invoked from any thread
Declaration
Swift
func addSdkStateDelegate(_ delegate: SdkStateDelegate)Parameters
delegateAn instance of a sdk state delegate to callback on.
-
Remove the delegate to stop listening to the state of the SDK Can be invoked from any thread
Declaration
Swift
func removeSdkStateDelegate(_ delegate: SdkStateDelegate)Parameters
delegateAn instance of a sdk state delegate to remove. The functions on this object will not be called back on anymore
-
addReaderUpdateDelegate(_:Default implementation) Adds a delegate for listening to updates from readers Can be invoked from any thread
Default Implementation
Extension which lets you call
addReaderUpdateDelegateand provide a block as the callback handler rather than having to implement theReaderUpdateDelegateprotocol yourself on a concrete classDeclaration
Swift
func addReaderUpdateDelegate(_ delegate: ReaderUpdateDelegate)Parameters
delegateAn instance of a reader update delegate to callback on.
-
Removes a delegate for listening to updates from readers Can be invoked from any thread
Declaration
Swift
func removeReaderUpdateDelegate(_ delegate: ReaderUpdateDelegate)Parameters
delegateAn instance of a reader update delegate to remove. The functions on this object will not be called back on anymore
-
Add a delegate to listen out for automatic access attempts from inside the SDK Can be invoked from any thread
Declaration
Swift
func addAutomaticAccessDelegate(_ delegate: AccessDelegate)Parameters
delegateThe access delegate that will start having its relevant methods called in response to automatic access attempts/errors/results
-
Removes an automatic access delegate by reference. Can be invoked from any thread
Declaration
Swift
func removeAutomaticAccessDelegate(_ delegate: AccessDelegate)Parameters
delegateAn instance of an access delegate to remove. The functions on this object will not be called back on anymore
-
Allows or Prevents the SDK from making automatic access attempts. If automatic access attempts are already allowed, then this does nothing. Automatic access attempts are disabled by default.
In order for automatic access attempts to work you must also instruct the SDK to start scanning for devices. Must get on the main thread, set on any thread
Declaration
Swift
var isAutomaticAccessEnabled: Bool { get set } -
Controls background reader scanning behaviour Must get on the main thread, set on any thread
Declaration
Swift
var backgroundScanningMode: BackgroundScanningMode { get set } -
A list of current global errors or warnings from the SDK Must get on the main thread
Declaration
Swift
var states: [MobileAccessState] { get }Return Value
The global errors or warnings from the SDK as a collection
-
Synchronously gets the feature states of the SDK Must get on the main thread
Declaration
Swift
var sdkFeatureStates: [SdkFeatureState] { get }Return Value
The feature states of the SDK as a collection
-
Listens to the feature states of the SDK. Warnings and errors will be announced via the handler provided Can be invoked from any thread
Declaration
Swift
func addSdkFeatureStateDelegate(_ delegate: SdkFeatureStateDelegate)Parameters
delegateAn instance of a feature state delegate to callback on.
-
Removes a feature state delegate by reference.
Declaration
Swift
func removeSdkFeatureStateDelegate(_ delegate: SdkFeatureStateDelegate)Parameters
delegateAn instance of a feature state delegate to remove. The functions on this object will not be called back on anymore.
-
Triggers an async request to the Gallagher cloud for related item updates for registered mobile credentials Resulting updates for Notifications, Salto Keys, Digital IDs will be published in the background through associated delegates Can be invoked from any thread
Declaration
Swift
func syncCredentialItemUpdates() -
Triggers an async request to the Gallagher cloud for related item updates for registered mobile credentials, calling
onSyncCompletedafter the sync process finishes. Resulting updates for Notifications, Salto Keys, Digital IDs will be published in the background through associated delegates Can be invoked from any threadDeclaration
Swift
func syncCredentialItemUpdates(onSyncCompleted: @escaping (Result<Void, Error>) -> ()) -
Add a delegate for handling Digital IDs available to registered Mobile Credentials Can be invoked from any thread
Declaration
Swift
func addDigitalIdDelegate(_ delegate: DigitalIdDelegate)Parameters
delegateThe delegate that will start having its relevant methods called with Digital ID updates
-
Removes a Digital ID delegate by reference Can be invoked from any thread
Declaration
Swift
func removeDigitalIdDelegate(_ delegate: DigitalIdDelegate)Parameters
delegateAn instance of a Digital ID delegate to remove. The functions on this object will not be called back on anymore
-
Add a delegate for handling Salto Keys available to registered MobileCredentials Can be invoked from any thread
Declaration
Swift
func addSaltoUpdateDelegate(_ delegate: SaltoUpdateDelegate)Parameters
delegateThe delegate that will start having its relevant methods called with Salto Key updates
-
Removes a Salto update delegate by reference Can be invoked from any thread
Declaration
Swift
func removeSaltoUpdateDelegate(_ delegate: SaltoUpdateDelegate)Parameters
delegateThe Salto delegate to be removed
-
Add a delegate for handling Wallets available to registered Mobile Credentials Can be invoked from any thread
Declaration
Swift
@available(iOS 16, *) func addWalletUpdateDelegate(_ delegate: WalletUpdateDelegate)Parameters
delegateThe delegate that will start having its relevant methods called with Wallet updates
-
Removes a Wallet update delegate by reference Can be invoked from any thread
Declaration
Swift
@available(iOS 16, *) func removeWalletUpdateDelegate(_ delegate: WalletUpdateDelegate)Parameters
delegateAn instance of a Wallet update delegate to remove. The functions on this object will not be called back on anymore
-
Triggers a wallet add and returns the result via a wallet provisioning delegate. Can be invoked from any thread
Declaration
Swift
@available(iOS 16, *) func startProvisioningWallet(_ wallet: Wallet, passThumbnailImage: UIImage, passDescription: String, presentingViewController: UIViewController, delegate: WalletProvisioningDelegate)Parameters
walletThe Wallet to provision
passThumbnailImageAn image to display in the Add to Wallet preview screen. It is recommended that this image matches final pass.
passDescriptionA description to display in the Add to Wallet preview screen.
presentingViewControllerThe view controller to present the Add to Wallet ViewController.
delegateAn instance of a Wallet provisioning delegate to return provisioning results to.
-
Start opening a Salto Door with a given Salto Key Identifier using default opening parameters with ‘.standardMode’ opening mode
Declaration
Swift
func startOpeningSaltoDoor(saltoKeyIdentifier: SaltoKeyIdentifier, delegate: SaltoAccessDelegate)Parameters
saltoKeyIdentifierThe Salto Key Identifier the user wants access with
delegateThe delegate that will have its methods called with peripheral found, access complete or an error received
-
Start opening a Salto Door with a given Salto Key Identifier using specified opening parameters
Declaration
Swift
func startOpeningSaltoDoor(saltoKeyIdentifier: SaltoKeyIdentifier, delegate: SaltoAccessDelegate, params: SaltoOpeningParams)Parameters
saltoKeyIdentifierThe Salto Key Identifier the user wants access with
delegateThe delegate that will have its methods called with peripheral found, access complete or an error received
paramsAdditional parameters for opening a Salto Door
-
Start opening the next (Gallagher) door we see within manual-connect range. This temporarily extends the “auto connect” range for a reader out to that reader’s “manual connect” range, so you can open the door from further away. The range extension remains active until the next door is encountered, or until
expiryseconds have elapsedDeclaration
Swift
func startOpeningNextDoor(expiry: TimeInterval, delegate: AccessDelegate)Parameters
expiryHow long to keep the range extension active for. A typical value is 5 seconds
delegateThe delegate that will have its methods called with the access result
-
registerCredential(url:Extension methodonRegistrationCompleted: onAuthenticationTypeSelectionRequested: ) Extension which lets you call
registerCredentialand provide two blocks as handlers foronRegistrationCompletedandonAuthenticationTypeSelectionRequested, rather than having to implement theRegistrationDelegateprotocol yourself on a concrete classDeclaration
Swift
@discardableResult func registerCredential( url:URL, onRegistrationCompleted: @escaping (_ credential:MobileCredential?, _ error:RegistrationError?) -> (), onAuthenticationTypeSelectionRequested: @escaping (_ selector: @escaping SecondFactorAuthenticationTypeSelector) -> ()) -> RegistrationDelegate -
addAutomaticAccessDelegate(onAccessStart:Extension methodonAccessCompleted: ) Extension which lets you call
addAutomaticAccessDelegateand provide two blocks as handlers foronAccessStartandonAccessCompleted, rather than having to implement theAccessDelegateprotocol yourself on a concrete classDeclaration
Swift
@discardableResult func addAutomaticAccessDelegate( onAccessStart: @escaping (_ reader: Reader) -> (), onAccessCompleted: @escaping (_ reader:Reader, _ result:AccessResult?, _ error:ReaderConnectionError?) -> ()) -> AccessDelegate -
requestAccess(reader:Extension methodonAccessStart: onAccessCompleted: ) Extension which lets you call
requestAccessand provide two blocks as handlers foronAccessStartandonAccessCompleted, rather than having to implement theAccessDelegateprotocol yourself on a concrete classDeclaration
Swift
@discardableResult func requestAccess( reader:Reader, onAccessStart: @escaping (_ reader: Reader) -> (), onAccessCompleted: @escaping (_ reader:Reader, _ result:AccessResult?, _ error:ReaderConnectionError?) -> ()) -> AccessDelegate -
addSdkStateDelegate(onStateChange:Extension method) Extension which lets you call
addSdkStateDelegateand provide a block as the callback handler rather than having to implement theSdkStateDelegateprotocol yourself on a concrete classDeclaration
Swift
@discardableResult func addSdkStateDelegate(onStateChange: @escaping (_ isScanning: Bool, _ states: [MobileAccessState]) -> ()) -> SdkStateDelegate -
addDigitalIdDelegate(onDigitalIdUpdate:Extension method) Extension which lets you call
addDigitalIdDelegateand provide a block as the callback handler rather than having to implement theDigitalIdDelegateprotocol yourself on a concrete classDeclaration
Swift
@discardableResult func addDigitalIdDelegate(onDigitalIdUpdate: @escaping (_ addedOrUpdatedDigitalIds: [DigitalId], _ removedDigitalIds: [DigitalId], _ lastUpdateTime: Date?) -> ()) -> DigitalIdDelegate -
addSdkFeatureStateDelegate(onFeatureStatesChanged:Extension methodonFeatureError: ) Extension which lets you call
addSdkFeatureStateDelegateand provide a block as the callback handler rather than having to implement theSdkFeatureStateDelegateprotocol yourself on a concrete classDeclaration
Swift
@discardableResult func addSdkFeatureStateDelegate(onFeatureStatesChanged: @escaping (_ featureStates: [SdkFeatureState]) -> (), onFeatureError: @escaping (_ error: Error) -> ()) -> SdkFeatureStateDelegate -
Extension which lets you call
startOpeningSaltoDoorand provide blocks for theperipheralFoundandsaltoAccessCompletedcallbacks, rather than having to implement theSaltoAccessDelegateprotocol yourself on a concrete classDeclaration
Swift
@discardableResult func startOpeningSaltoDoor( saltoKeyIdentifier: SaltoKeyIdentifier, peripheralFound: @escaping () -> (), saltoAccessCompleted: @escaping (Result<SaltoAccessResult, SaltoError>) -> ()) -> SaltoAccessDelegate -
startOpeningSaltoDoor(saltoKeyIdentifier:Extension methodperipheralFound: saltoAccessCompleted: params: ) Extension which lets you call
startOpeningSaltoDoorwith Salto openingparamsand provide blocks for theperipheralFoundandsaltoAccessCompletedcallbacks, rather than having to implement theSaltoAccessDelegateprotocol yourself on a concrete classDeclaration
Swift
@discardableResult func startOpeningSaltoDoor( saltoKeyIdentifier: SaltoKeyIdentifier, peripheralFound: @escaping () -> (), saltoAccessCompleted: @escaping (Result<SaltoAccessResult, SaltoError>) -> (), params: SaltoOpeningParams) -> SaltoAccessDelegate -
startOpeningNextDoor(expiry:Extension methodonAccessStart: onAccessCompleted: ) Extension which lets you call
startOpeningNextDoorand provide two blocks as handlers foronAccessStartandonAccessCompleted, rather than having to implement theAccessDelegateprotocol yourself on a concrete classDeclaration
Swift
@discardableResult func startOpeningNextDoor( expiry: TimeInterval, onAccessStart: @escaping (_ reader: Reader) -> (), onAccessCompleted: @escaping (_ reader:Reader, _ result:AccessResult?, _ error:ReaderConnectionError?) -> ()) -> AccessDelegate -
startProvisioningWallet(_:Extension methodpassThumbnailImage: passDescription: presentingViewController: onWalletMigrationDetected: onWalletProvisioningCompleted: ) Extension which lets you call
startWalletProvisioningand provide a block handler foronWalletMigrationDetectedandonProvisioningCompleted, rather than having to implement theWalletProvisioningDelegateprotocol yourself on a concrete classDeclaration
Swift
@available(iOS 16, *) @discardableResult func startProvisioningWallet( _ wallet:Wallet, passThumbnailImage: UIImage, passDescription:String, presentingViewController:UIViewController, onWalletMigrationDetected: @escaping (_ handler: @escaping WalletMigrationHandler) ->(), onWalletProvisioningCompleted: @escaping (_ wallet:Wallet, _ succeeded:Bool, _ error: WalletProvisioningError?) -> ()) -> WalletProvisioningDelegate
MobileAccess Protocol Reference