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 RegistrationDelegate to be notified about, and interact with the registration process

    Note: 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 resolveInvitationUri to build a fully qualified URI

    Declaration

    Swift

    func registerCredential(url: URL, delegate: RegistrationDelegate)

    Parameters

    url

    credential registration URL

    delegate

    a 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

    options

    Whether 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

    credentialId

    credential 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 .allowOffline or .offlineOnly for deleteOption

    Declaration

    Swift

    func deleteMobileCredential(_ mobileCredential: MobileCredential, deleteOption: DeleteOption, onCredentialDeleteCompleted: @escaping CredentialDeleteCompletedHandler)

    Parameters

    mobileCredential

    The mobile credential to delete

    deleteOption

    Advanced usage if you need to delete credentials while offline.

    onCredentialDeleteCompleted

    Callback 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 isScanning because 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 use addSdkStateDelegate to provide a callback.

    Refer to states:[MobileAccessState] for potential scanning problems and warnings

    Can be invoked from any thread

    Declaration

    Swift

    func setScanning(enabled: Bool)

    Parameters

    enabled

    If 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

    rawUrl

    region URL

    invitation

    invitation 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

    reader

    The reader to request access by

    delegate

    The 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

    reader

    The reader to request action for

    action

    action to perform

    onReaderActionCompleted

    Returns reader and action of 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

    reader

    The reader to enumerate the actions for

    onReaderActionEnumerationCompleted

    Returns the reader and 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

    delegate

    An 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

    delegate

    An 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 addReaderUpdateDelegate and provide a block as the callback handler rather than having to implement the ReaderUpdateDelegate protocol yourself on a concrete class

    Declaration

    Swift

    func addReaderUpdateDelegate(_ delegate: ReaderUpdateDelegate)

    Parameters

    delegate

    An 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

    delegate

    An 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

    delegate

    The 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

    delegate

    An 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

    delegate

    An instance of a feature state delegate to callback on.

  • Removes a feature state delegate by reference.

    Declaration

    Swift

    func removeSdkFeatureStateDelegate(_ delegate: SdkFeatureStateDelegate)

    Parameters

    delegate

    An 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 onSyncCompleted after 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 thread

    Declaration

    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

    delegate

    The 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

    delegate

    An 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

    delegate

    The 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

    delegate

    The 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

    delegate

    The 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

    delegate

    An 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

    wallet

    The Wallet to provision

    passThumbnailImage

    An image to display in the Add to Wallet preview screen. It is recommended that this image matches final pass.

    passDescription

    A description to display in the Add to Wallet preview screen.

    presentingViewController

    The view controller to present the Add to Wallet ViewController.

    delegate

    An 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

    saltoKeyIdentifier

    The Salto Key Identifier the user wants access with

    delegate

    The 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

    saltoKeyIdentifier

    The Salto Key Identifier the user wants access with

    delegate

    The delegate that will have its methods called with peripheral found, access complete or an error received

    params

    Additional 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 expiry seconds have elapsed

    Declaration

    Swift

    func startOpeningNextDoor(expiry: TimeInterval, delegate: AccessDelegate)

    Parameters

    expiry

    How long to keep the range extension active for. A typical value is 5 seconds

    delegate

    The delegate that will have its methods called with the access result

  • Extension which lets you call registerCredential and provide two blocks as handlers for onRegistrationCompleted and onAuthenticationTypeSelectionRequested, rather than having to implement the RegistrationDelegate protocol yourself on a concrete class

    Declaration

    Swift

    @discardableResult
    func registerCredential(
        url:URL,
        onRegistrationCompleted: @escaping (_ credential:MobileCredential?, _ error:RegistrationError?) -> (),
        onAuthenticationTypeSelectionRequested: @escaping (_ selector: @escaping SecondFactorAuthenticationTypeSelector) -> ()) -> RegistrationDelegate
  • Extension which lets you call addAutomaticAccessDelegate and provide two blocks as handlers for onAccessStart and onAccessCompleted, rather than having to implement the AccessDelegate protocol yourself on a concrete class

    Declaration

    Swift

    @discardableResult
    func addAutomaticAccessDelegate(
        onAccessStart: @escaping (_ reader: Reader) -> (),
        onAccessCompleted: @escaping (_ reader:Reader, _ result:AccessResult?, _ error:ReaderConnectionError?) -> ()) -> AccessDelegate
  • Extension which lets you call requestAccess and provide two blocks as handlers for onAccessStart and onAccessCompleted, rather than having to implement the AccessDelegate protocol yourself on a concrete class

    Declaration

    Swift

    @discardableResult
    func requestAccess(
        reader:Reader,
        onAccessStart: @escaping (_ reader: Reader) -> (),
        onAccessCompleted: @escaping (_ reader:Reader, _ result:AccessResult?, _ error:ReaderConnectionError?) -> ()) -> AccessDelegate
  • Extension which lets you call addSdkStateDelegate and provide a block as the callback handler rather than having to implement the SdkStateDelegate protocol yourself on a concrete class

    Declaration

    Swift

    @discardableResult
    func addSdkStateDelegate(onStateChange: @escaping (_ isScanning: Bool, _ states: [MobileAccessState]) -> ()) -> SdkStateDelegate
  • Extension which lets you call addDigitalIdDelegate and provide a block as the callback handler rather than having to implement the DigitalIdDelegate protocol yourself on a concrete class

    Declaration

    Swift

    @discardableResult
    func addDigitalIdDelegate(onDigitalIdUpdate: @escaping (_ addedOrUpdatedDigitalIds: [DigitalId], _ removedDigitalIds: [DigitalId], _ lastUpdateTime: Date?) -> ()) -> DigitalIdDelegate
  • Extension which lets you call addSdkFeatureStateDelegate and provide a block as the callback handler rather than having to implement the SdkFeatureStateDelegate protocol yourself on a concrete class

    Declaration

    Swift

    @discardableResult
    func addSdkFeatureStateDelegate(onFeatureStatesChanged: @escaping (_ featureStates: [SdkFeatureState]) -> (), onFeatureError: @escaping (_ error: Error) -> ()) -> SdkFeatureStateDelegate
  • Extension which lets you call startOpeningSaltoDoor and provide blocks for the peripheralFound and saltoAccessCompleted callbacks, rather than having to implement the SaltoAccessDelegate protocol yourself on a concrete class

    Declaration

    Swift

    @discardableResult
    func startOpeningSaltoDoor(
        saltoKeyIdentifier: SaltoKeyIdentifier,
        peripheralFound: @escaping () -> (),
        saltoAccessCompleted: @escaping (Result<SaltoAccessResult, SaltoError>) -> ()) -> SaltoAccessDelegate
  • Extension which lets you call startOpeningSaltoDoor with Salto opening params and provide blocks for the peripheralFound and saltoAccessCompleted callbacks, rather than having to implement the SaltoAccessDelegate protocol yourself on a concrete class

    Declaration

    Swift

    @discardableResult
    func startOpeningSaltoDoor(
        saltoKeyIdentifier: SaltoKeyIdentifier,
        peripheralFound: @escaping () -> (),
        saltoAccessCompleted: @escaping (Result<SaltoAccessResult, SaltoError>) -> (),
        params: SaltoOpeningParams) -> SaltoAccessDelegate
  • Extension which lets you call startOpeningNextDoor and provide two blocks as handlers for onAccessStart and onAccessCompleted, rather than having to implement the AccessDelegate protocol yourself on a concrete class

    Declaration

    Swift

    @discardableResult
    func startOpeningNextDoor(
        expiry: TimeInterval,
        onAccessStart: @escaping (_ reader: Reader) -> (),
        onAccessCompleted: @escaping (_ reader:Reader, _ result:AccessResult?, _ error:ReaderConnectionError?) -> ()) -> AccessDelegate
  • Extension which lets you call startWalletProvisioning and provide a block handler for onWalletMigrationDetected and onProvisioningCompleted, rather than having to implement the WalletProvisioningDelegate protocol yourself on a concrete class

    Declaration

    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