Classes
The following classes are available globally.
-
A collection of error codes related to the SDK authentication.
See moreDeclaration
Swift
public class TKMAuthenticationHandlerErrorCodes
-
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
TKMCancellationToken
See also
TKMPromise<T>
Declaration
Swift
public class TKMCancellationTokenSource
-
Undocumented
See moreDeclaration
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 aTKMPromise<T>
, likecontinueOnUi(continuation:)
,catchOnUi(errorHandler:)
, etc., capture theTKMAsyncScheduler
as returned byTKMAsyncSchedulers.current()
at the time the method is called and associate it with the returnedTKMPromise<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 accordingTKMAsyncScheduler
or by usingTKMAsync.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
Declaration
Swift
public class TKMPromise<T>
-
Instances of this class are used to create and complete
See moreTKMPromise<T>
instances. Instances of this class are produced with a reference to anTKMAsyncScheduler
, which is used to invoke continuations on the returnedTKMPromise<T>
. By default, the current scheduler is captured when calling the constructor.Declaration
Swift
public class TKMPromiseSource<T>
-
An TKMAsyncError represents an error that occurred during an asynchronous operation.
See moreDeclaration
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
See moreerrorCode
must be inspected.Declaration
Swift
public class TKMError : Error
-
A nearby Tapkey lock discovered via Bluetooth. Do not instantiate but use
See moreTKMBleLockScanner
to get nearby Tapkey locks.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 moreDeclaration
Swift
public class TKMCommandResult : NSObject
-
Contains information about an error that occurred in a component inside the SDK.
See moreDeclaration
Swift
public class TKMErrorDescriptor
-
A set of information on a locally available mobile key.
See moreDeclaration
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:
See more// Within the UIApplicationDelegate.application(application:didFinishLaunchingWithOptions:) let environmentConfigBuilder = TKMEnvironmentConfigBuilder() let environmentConfig = environmentConfigBuilder.build()
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
TKMServiceFactoryDeclaration
Swift
@objc(TKMServiceFactoryBuilder) public class TKMServiceFactoryBuilder : NSObject
-
Represents an observable object with a given type. The observable can be observed.
See moreDeclaration
Swift
public class TKMObservable<T> : NSObject