Protocols

The following protocols are available globally.

  • Handles refreshing of authentication information. Needs to be implemented by the user of the SDK and passed to the Tapkey service factory builder prior to logging in the first users.

    See more

    Declaration

    Swift

    public protocol TKMTokenRefreshHandler
  • The BLE (Bluetooth Low Energy) lock communicator provides means to communicate with Tapkey locks via BLE. It can be used to send commands to locks.

    Use TKMServiceFactory to retrieve an instance of BleLockCommunicator.

    See more

    Declaration

    Swift

    public protocol TKMBleLockCommunicator
  • The BLE (Bluetooth Low Energy) lock scanner provides means to scan for Tapkey locks via BLE. It can be used to scan for nearby locks and to determine whether a specific lock is nearby.

    Use TKMServiceFactory to retrieve an instance of BleLockScanner.

    See more

    Declaration

    Swift

    public protocol TKMBleLockScanner
  • Offers commands to be executed on Tapkey locks. Methods of this class expect a TLCP connection to a Tapkey lock and take a cancellation token for execution control.

    The example below outlines a possible usage of triggerLockAsync(lock:cancellationToken:). In the present example, the required TLCP connection is established using the TKMBleLockCommunicator.

    // The Bluetooth Communicator establishes a connection to the Tapkey lock via Bluetooth and lets
    // the CommandExecutionFacade use this connection to execute a TriggerLock command.
    return bleLockCommunicator.executeCommandAsync(bluetoothAddress, physicalLockId, { tlcpConnection in
    
        // Now, with the TlcpConnection to the lock available, the TKMCommandExecutionFacade
        // asynchronously executes the trigger lock command.
        return commandExecutionFacade.triggerLockAsync(tlcpConnection, cancellationToken: ct)
    
    }, ct).continueOnUi { commandResult -> Bool in
    
        switch (commandResult.code) {
            case Ok:
                return true
            // Handle error results.
            ...
        }
        return false
    
    }.catchOnUi { e -> Bool in
    
        Log.e(TAG, "Could not execute trigger lock command.", e)
        if (!ct.isCancellationRequested()) {
             // Handle any exceptions and let the user know, something went wrong.
        }
        return false
    
    }
    
    See more

    Declaration

    Swift

    public protocol TKMCommandExecutionFacade
  • The key manager provides access to the available mobile keys on this device. The SDK fetches mobile keys for all logged-in users and stores them locally when NotificationManager.pollForNotificationsAsync(cancellationToken:) is called. The key manager then takes care of automatically renewing local mobile keys in time. The SDK does not return the actual mobile keys, but only a set of details about the key.

    See more

    Declaration

    Swift

    public protocol TKMKeyManager
  • Provides methods to poll for updates from the Tapkey Trust Service.

    See more

    Declaration

    Swift

    public protocol TKMNotificationManager
  • The support manager provides access to information about the current environment. Information returned by this class may be included in crash reports, logs etc. to make it easier to investigate issues with the SDK.

    See more

    Declaration

    Swift

    public protocol TKMSupportManager
  • The user manager takes care of user authentication and provides access to the currently logged-in users.

    The following code sample illustrates how to use this class to retrieve the list of logged-in users.

    let userManager = tapkeyServiceFactory.userManager
    let users = userManager.users
    
    // Now, users contains a list of IDs of all logged-in users. Usually, users.count will be 1,
    // however, it is possible to log in multiple users at the same time.
    

    The exemplary code below demonstrates how to log in a user:

    let userManager = tapkeyServiceFactory.userManager
    userManager.logInAsync(accessToken: tapkeyAccessToken, cancellationToken: ct)
    

    Implementors have to make sure that a token refresh handler was set via the TKMServiceFactory builder prior to logging in any users.

    See more

    Declaration

    Swift

    public protocol TKMUserManager
  • The Tapkey service factory provides access to core components of the Tapkey Mobile SDK. This interface is not to be implemented by consuming applications. Instead, the platform-specific factory builders are to be used to retrieve an instance.

    See more

    Declaration

    Swift

    public protocol TKMServiceFactory
  • An object that represents the registration on an Observable. An ObserverRegistration can be used to unregister an Observable.

    See more

    Declaration

    Swift

    public protocol TKMObserverRegistration