Skip to content

2.3.0.0 and Later

Updated Key Manager

The method signature of TKMKeyManager.queryLocalKeysAsync(...) has changed from

TKMKeyManager.queryLocalKeysAsync(userId:forceUpdate:cancellationToken:)

to

TKMKeyManager.queryLocalKeysAsync(userId:cancellationToken:)

The parameter forceUpdate did only refresh the keys' grant information, which was deprecated in 2.2.0.0 and must not be used anymore. Consult the Swift documentation for more information.

Migration

Omit the forceUpdate parameter when calling TKMKeyManager.queryLocalKeysAsync(...). This won't affect your application's behavior unless you were using deprecated parts of the SDK.

Improved Async Framework

The async framework was updated to work with Swift errors instead of NSExceptions.

Error Handling in Promise Chains

Both TKMPromise.catchOnUi and TKMPromise.catchAsyncOnUi now return a Swift error instead of a NSException.

// Replace
aPromise.catchOnUi { (exception: NSException?) -> String?
    // Exception handling
}

// with
aPromise.catchOnUi { (error: Error) -> String?
    // Error handling
}

Throwing an Error Inside Promise Chain

TKMPromise now supports throwing an Error inside a continuation instead of raising an NSException.

//Replace
aPromise.continueOnUI { x -> String? as
    NSException(...).raise()
}

// with
aPromise.continueOnUI { x throws -> String? as
    throw CustomError.someErrorCase
}

Creating a Promise From an Error

Instead of creating a promise from NSException, TKMAsync now allows to create a TKMPromise from an error:

// Replace
let promise = TKMAsync.promiseFromException(TKMException(...))

// with
let promise = TKMAsync.promiseFromError(CustomError.someErrorCase)

Migration

When migrating from previous versions of the Tapkey Mobile SDK for iOS to 2.3.0.0, the changes described above have to be applied. This is especially true for the TKMTokenRefreshHandler, as the SDK is expecting a TKMError with code TKMAuthenticationHandlerErrorCodes.TokenRefreshFailed to be raised in case the authentication cannot be renewed at this time.

public class MyTokenRefreshHandler: TKMTokenRefreshHandler {

    ...

    func refreshAuthenticationAsync(userId: String, cancellationToken: TKMCancellationToken)
    -> TKMPromise<String> {

        do {
            // Custom application logic to retrieve a new access token
            return try getNewAccessToken(userId, cancellationToken)
        } catch (e) {
            return TKMAsync.promiseFromError(TKMError(errorDescriptor: TKMErrorDescriptor(
                code: TKMAuthenticationHandlerErrorCodes.TokenRefreshFailed,
                message: "No new token can be obtained.",
                details: e)))
        }
    }

    ...

}