Classes

The following classes are available globally.

  • A collection of error codes related to the SDK authentication.

    See more

    Declaration

    Swift

    public class TKMAuthenticationHandlerErrorCodes
  • Undocumented

    See more

    Declaration

    Swift

    public class TKMAsync
  • This class provides functionality to cancel pending promises. It is a source for cancellation tokens.

    The example below demonstrates how to retrieve a CancellationToken and use it to cancel a pending operation.

    let cancellationTokenSource = TKMCancellationTokenSource()
    let ct = cancellationTokenSource.token
    
    //Pass the token to an asynchronous operation that accepts a CancellationToken
    asyncOperation(..., ct).conclude()
    
    // If required, cancellation can be requested as follows:
    cancellationTokenSource.requestCancellation()
    

    See also

    TKMPromise<T>
    See more

    Declaration

    Swift

    public class TKMCancellationTokenSource
  • Undocumented

    See more

    Declaration

    Swift

    public class TKMCancellationTokens
  • Implementation of the promise pattern, used for composing async program flows. All asynchronous operations within the Tapkey Mobile SDK will return instances of this class.

    Promises allow waiting for the outcome of an operation in an async manner. Instead of waiting synchronously, callbacks, so called continuations, can be registered that are invoked on completion.

    Async functions returning promises can be composed to build async flows.

    Continuations are run on the TKMAsyncScheduler a promise was created with. Methods of this class that return a TKMPromise<T>, like continueOnUi(continuation:), catchOnUi(errorHandler:), etc., capture the TKMAsyncScheduler as returned by TKMAsyncSchedulers.current() at the time the method is called and associate it with the returned TKMPromise<T>.

    Most often promises are produced and continuations registered on the UI thread, which implies, that continuations will also run on the UI thread and subsequent TKMPromise<T>s are also associated with the UI thread. This is why functions for registering continuations contain the term ‘Ui’. Running all functionality on the UI thread makes synchronization between async functions very easy, because there is no multi-threading involved. This implies, however, that these functions may only run for a very short period of time in order not to compromise the user experience. Long running operations should be run on a separate worker thread by switching to an according TKMAsyncScheduler or by using TKMAsync.executeAsync(f:).

    The following exemplary code demonstrates an asynchronous method that returns a Promise.

    public func getStringAsync() -> TKPromise<String> {
        let promiseSource = TKMPromiseSource<String>()
    
        // Trigger a long-running operation
        getStringFromServer {(text: String?, optError: Error?) -> Void in
            if let error = optError {
                promiseSource.setError(error)
                return
            }
            promiseSource.setResult(text)
        }
        return promiseSource.promise
    }
    

    The example code below illustrates how to chain promises:

    getTextFromServer()
        .continueAsyncOnUi { text in
            return uploadTextToAnotherServer(text)
        }
        .continueOnUi { result in
            TKMLog.d(TAG, "Upload completed: \(result)")
            return nil
        }
        .catchOnUi { e in
            TKMLog.e(TAG, "Something went wrong.", e)
            return nil
        }
        .conclude()
    

    See also

    TKMAsync
    See more

    Declaration

    Swift

    public class TKMPromise<T>
  • Instances of this class are used to create and complete TKMPromise<T> instances. Instances of this class are produced with a reference to an TKMAsyncScheduler, which is used to invoke continuations on the returned TKMPromise<T>. By default, the current scheduler is captured when calling the constructor.

    See more

    Declaration

    Swift

    public class TKMPromiseSource<T>
  • An TKMAsyncError represents an error that occurred during an asynchronous operation.

    See more

    Declaration

    Swift

    public class TKMAsyncError : Error
  • TKMError is used to represent errors inside many of the SDK’s components. To retrieve more information about the type of exception, the result of errorCode must be inspected.

    See more

    Declaration

    Swift

    public class TKMError : Error
  • A nearby Tapkey lock discovered via Bluetooth. Do not instantiate but use TKMBleLockScanner to get nearby Tapkey locks.

    See more

    Declaration

    Swift

    @objc
    public class TKMBleLock : NSObject
  • The result of a command, returned by a Tapkey lock. Contains a result code and additional response data.

    See more

    Declaration

    Swift

    public class TKMCommandResult : NSObject
  • Contains information about an error that occurred in a component inside the SDK.

    See more

    Declaration

    Swift

    public class TKMErrorDescriptor
  • A set of information on a locally available mobile key.

    See more

    Declaration

    Swift

    @objc(TKMKeyDetails)
    public class TKMKeyDetails : NSObject
  • Reserved for internal use.

    Declaration

    Swift

    public class TKMLockState
  • This class provides a Tapkey environment configuration. Unless suggested otherwise by Tapkey, this class must be used as shown below:

    // Within the UIApplicationDelegate.application(application:didFinishLaunchingWithOptions:)
    let environmentConfigBuilder = TKMEnvironmentConfigBuilder()
    let environmentConfig = environmentConfigBuilder.build()
    
    See more

    Declaration

    Swift

    @objc(TKMEnvironmentConfigBuilder)
    public class TKMEnvironmentConfigBuilder : NSObject
  • This class is used to build a TKMServiceFactory.

    The example below illustrates a default use of this class and will cover most use cases:

     let b = TKMServiceFactoryBuilder()
     let tapkeyServiceFactory = b.build()
    

    See also

    TKMServiceFactory
    See more

    Declaration

    Swift

    @objc(TKMServiceFactoryBuilder)
    public class TKMServiceFactoryBuilder : NSObject
  • Represents an observable object with a given type. The observable can be observed.

    See more

    Declaration

    Swift

    public class TKMObservable<T> : NSObject