Skip to Content

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.

Initializing the SDK
func initialize( instanceID: String = defaultInstanceID, userAuthRequiredOnInitialize: Bool = true, credentialIssuanceConfiguration: CredentialIssuanceConfiguration? = nil, loggerConfiguration: LoggerConfiguration = LoggerConfiguration() ) throws

Initialize a specific instance

You can initialize this singleton class with one instanceId at a time:

Initializing a specific instance
init() { do { mobileCredentialHolder = MobileCredentialHolder.shared try mobileCredentialHolder.initialize(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 userAuthRequiredOnInitialize parameter:

Requiring user authentication to initialize the SDK
init() { do { mobileCredentialHolder = MobileCredentialHolder.shared try mobileCredentialHolder.initialize(userAuthRequiredOnInitialize: true) } catch { print(error) } }

Configure OID4VCI

Use the CredentialIssuanceConfiguration struct to enable credential retrieval via OID4VCI:

Requiring user authentication to initialize the SDK
init() { do { mobileCredentialHolder = MobileCredentialHolder.shared try mobileCredentialHolder.initialize( credentialIssuanceConfiguration: CredentialIssuanceConfiguration( redirectUri: Constants.redirectUri, autoTrustMobileCredentialIaca: true ) ) } catch { print(error) } }
  • CredentialIssuanceConfiguration :
    • redirectUri: This is the URI that the SDK uses to redirect the user back to your wallet application after authentication is complete.
    • autoTrustMobileCredentialIaca: Controls how the SDK handles issuer IACA certificates during credential issuance.
      • If set to true, the SDK will automatically download and trust the issuer’s IACA certificate(s) when claiming a credential. This allows credentials to be claimed from any issuer.
      • If set to false, the SDK will only accept credentials from issuers whose IACA certificates have already been manually added to the SDK’s trusted issuers list (see addTrustedIssuerCertificates). This requires the application to manually manage IACA certificates.

UX Considerations

Setting userAuthRequiredOnInitialise to true would require the user to authenticate when initializing the SDK. To enable users to authenticate via Face ID you must add the NSFaceIDUsageDescription attribute to the application’s info.plist file.

Configure logger behavior

You can configure the SDK’s logger behavior using the optional loggerConfiguration parameter:

Configure logger behavior
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 .initialize( loggerConfiguration: loggerConfiguration ) } catch { print(error) } }
  • logLevel : Determines which events are written to log files:
  • callbackLogLevel : Determines which events invoke the callback function:
  • callback : Defines the function to call when events defined by callbackLogLevel 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).
Last updated on