initialize

suspend fun initialize(context: Context, instanceId: String = DEFAULT_INSTANCE_ID, userAuthenticationConfiguration: UserAuthenticationConfiguration = ConfigurationRepository.defaultUserAuthenticationConfiguration, credentialIssuanceConfiguration: CredentialIssuanceConfiguration? = null, dcmConfiguration: DcmConfiguration? = null, loggerConfiguration: Logger.LoggerConfiguration? = null, activityLogConfiguration: ActivityLogConfiguration? = null, platformConfiguration: PlatformConfiguration? = null)

Initialize the MobileCredentialHolder SDK.

The MobileCredentialHolder class is a singleton which can only be initialized with one instanceId at a time. After the initialize method has been called with a specific instanceId, all subsequent method calls in this class, such as getTrustedIssuerCertificates, will return a result unique to the specified instanceId.

Depending on configuration defined in UserAuthenticationConfiguration, this function may require user authentication to execute successfully. If a suitable user authentication mechanism is not setup on the device OR authentication fails for some reason, suitable exceptions will be thrown.

If a user disables authentication on their device after the SDK has already been initialized they will lose all access to their stored credentials, even if they re-enable authentication later. That is because when authentication is disabled, all associated keys become permanently invalid. This means that the key used to decrypt the credentials storage will no longer be available and a HolderException.UserAuthenticationUnrecoverableKeyException will be thrown. To resolve this issue the instance must be deleted using the destroy API and re-initialized.

On the first initialization, the app is registered with the MATTR VII tenant defined in platformConfiguration. On subsequent initializations, the existing license is renewed if necessary. Network access is required when registration or license renewal is performed.

The SDK uses Hardware key attestation to help prove requests come from legitimate instances of your app.

Parameters

context

Android Context. Must be an Activity if user authentication is set to UserAuthenticationBehavior.OnInitialize

instanceId

Optional parameter to identify the instance to configure when initializing the SDK. This will load all certificates and credentials unique to this instance. If the instance is empty, the default instance will be used.

userAuthenticationConfiguration

Optionally configure user authentication for storage and presentation. Default value is UserAuthenticationBehavior.Always with a presentation timeout of 20 seconds. This value cannot be changed over the lifetime of a specific instance. HolderException.UserAuthenticationConfigurationChangedException will be thrown if this option is changed.

credentialIssuanceConfiguration

Optional parameter, containing configuration options for credential issuance.

loggerConfiguration

Optional parameter to configure the logger behavior.

dcmConfiguration

Configuration for Android's Digital Credential Manager (DCM).

Throws

If an Activity is not supplied when required.

If the user cancels the authentication process.

If biometric authentication is locked out.

If the user has not set up authentication.

for general authentication failures.

If storage initialization fails.

If the SDK was already initialized.

If user authentication behavior changes during initialization.

If the SDK license is invalid or has expired. Re-initialize the SDK to obtain a new license.

If the holder app instance cannot be registered with the configured MATTR VII tenant during initialization.