Initializing the SDK
To use the SDK’s methods and classes, your application must call the SDK’s
initialize
method to initialize the
MobileCredentialHolder
class.
MobileCredentialHolder.getInstance().initialize(activity)
Initialize a specific instance
You can initialize this singleton class with one instanceId
at a time:
MobileCredentialHolder.getInstance().initialize(activity, instanceId = "user-2")
Once initialized, all subsequent method calls in this class will only return results specific to
this instanceId
.
If no instanceId
is provided, the default instance is initialized
(00000000-0000-0000-0000-000000000000
).
Configure authentication requirements
You can configure the method to require user authentication (biometric or passcode) upon
initialization using the optional userAuthRequiredOnInitialise
parameter:
MobileCredentialHolder.getInstance().initialize(activity, userAuthRequiredOnInitialize = false)
UX Considerations
Setting userAuthRequiredOnInitialize
to true
would require the user to authenticate when
initializing the SDK.
Configure credential issuance
When initializing the SDK, you should also configure the values required for credential issuance:
MobileCredentialHolder.getInstance().initialize(
activity,
credentialIssuanceConfiguration = CredentialIssuanceConfiguration(
redirectUri = Constants.REDIRECT_URI,
autoTrustMobileCredentialIaca = true
)
)
redirectUri
: This parameter is used by the issuer to redirect the user back to a specific view in your application after completing the configured OID4VCI workflow.- It must be defined as a resource in your application project, as shown in the Claim a credential tutorial.
- It must be registered as a key pair with
clientId
as part of the issuer’s OID4VCI workflow configuration.
autoTrustMobileCredentialIaca
:- When set to
true
, this request will accept credentials from any issuer. The SDK will retrieve the IACA referenced in the offered credential and add it to the list of trusted issuers in the application storage. - When set to
false
, this request will only accept credentials issued by trusted issuers, identified by their IACA certificate. This means the IACA referenced in the offered credential must exist in the application’s trusted issuers list prior to accepting the credential offer.
- When set to
See the Claim and manage credentials usage guide for more details.
Configure logger behavior
You can configure the SDK’s logger behavior using the optional loggerConfiguration
parameter:
MobileCredentialHolder.getInstance().initialize(
activity,
loggerConfiguration = Logger.LoggerConfiguration(
logLevel = Logger.LogLevel.DEBUG,
callbackLogLevel = Logger.LogLevel.DEBUG,
callback = { priority, tag, message, error ->
Logger.d("Perform any custom action with the log event: $message")
}
)
)
logLevel
: Determines which events are written to logs.callbackLogLevel
: Determines which events invoke thecallback
function.callback
: Defines the function to call when events defined bycallbackLogLevel
occur.
Logging levels
These levels apply to both the logLevel
and callbackLogLevel
parameters (corresponding raw value
in shown in parenthesis):
- Off (7).
- Assert (7).
- Error (6).
- Warning (5).
- Info (4).
- Debug (3).
- Verbose (2).