Initializing the SDK
To use the SDK’s methods and classes, your application must call the SDK’s
initialise
method to initialize the
MobileCredentialHolder
class.
func initialise(
instanceID: String = defaultInstanceID,
userAuthRequiredOnInitialise: Bool = true,
loggerConfiguration: LoggerConfiguration = LoggerConfiguration()
) throws
Initialize a specific instance
You can initialize this singleton class with one instanceId
at a time:
init() {
do {
mobileCredentialHolder = MobileCredentialHolder.shared
try mobileCredentialHolder.initialise(instanceID: "1234")
} catch {
print(error)
}
}
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:
init() {
do {
mobileCredentialHolder = MobileCredentialHolder.shared
try mobileCredentialHolder.initialise(userAuthRequiredOnInitialise: true)
} catch {
print(error)
}
}
UX Considerations and best practices
Setting userAuthRequiredOnInitialise
to true
would require granting bluetooth permissions to
your wallet application. To enable this, you must add the NSBluetoothAlwaysUsageDescription
attribute to the application’s info.plist
file.
Configure logger behavior
You can configure the SDK’s logger behavior using the optional loggerConfiguration
parameter:
init() {
do {
let loggerConfiguration = LoggerConfiguration(
logLevel: .Debug,
callbackLogLevel: .Debug) { event in
print(
"Perform any custom action with the log event: \(event.message)"
)
}
mobileCredentialHolder = MobileCredentialHolder.shared
try mobileCredentialHolder
.initialise(
loggerConfiguration: loggerConfiguration
)
} catch {
print(error)
}
}
logLevel
: Determines which events are written to log files: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 (0).
- Error (1).
- Warning (2).
- Info (3).
- Debug (4).
- Verbose (5).