> For the complete documentation index, see [llms.txt](https://docs.payments.thalescloud.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.payments.thalescloud.io/nfc-wallet-sdk-ios/get-started/configuration/3.-initialization.md).

# 3. Initialization

## NFC Wallet SDK initialization <a href="#tsh-pay-sdk-initialisation" id="tsh-pay-sdk-initialisation"></a>

{% hint style="info" %}
**Note**

NFC Wallet SDK does not support iCloud and device backup restore feature.
{% endhint %}

The digital wallet application (wallet) must initialize the SDK before the NFC Wallet SDK features can be used.

You can use `TSHPay.configure` API to initialise the SDK. The wallet is required to provide two parameters:

* Cardholder verfication method (CVM)
* Configuration PLIST file

The initialisation of the SDK must be performed each time the application is launched.

### Cardholder verification method <a href="#cardholder-verification-method" id="cardholder-verification-method"></a>

The wallet is required to provide the authentication method during SDK initialisation. One of the following authentication methods is selected:

* `.userPresence` : An authentication method using biometrics (TouchID/FaceID) with fallback to device passcode, or to use device passcode in cases where the biometrics are removed after the card digitization process. MPA can change the authentication method to biometrics or device passcode during the payment verification step.
* `biometricOnly` :An authentication method using TouchID/FaceID only.

For more details about the cardholder verification method, refer to the API documentation.

### Configure PLIST file <a href="#configuration-plist-file" id="configuration-plist-file"></a>

A PLIST file has to be created and stored in the main bundle of the mobile application.

**TSHPay.plist**

<details>

<summary>TSHPay.plist parameters description</summary>

<table><thead><tr><th width="374">KEY</th><th>COMMENT</th></tr></thead><tbody><tr><td>REALM</td><td>[String] A fixed parameter. For example, "CBP".</td></tr><tr><td>OAUTH_CONSUMER_KEY</td><td>[String] Consumer Key which is to be provided by Thales.</td></tr><tr><td>GATEWAY_URL</td><td>[String] The URL of the Rages which is to be provided by Thales.</td></tr><tr><td>CSR_DOMAIN</td><td>[String] Used for Certificate Signing Request in the component that secures the HTTPS calls. Refer to your Thales integrator for the value to be set.</td></tr><tr><td>CSR_EMAIL</td><td>[String] Company email.</td></tr><tr><td>CPS_URL</td><td>[String] The URL of the CPS server which is to be provided by your Thales integrator.</td></tr><tr><td>MG_CONNECTION_URL</td><td>[String] The URL of the MG server which is to be provided by Thales.</td></tr><tr><td>MG_WALLET_PROVIDER_ID</td><td>[String] The ID of the wallet provider.</td></tr><tr><td>MG_WALLET_APPLICATION_ID</td><td>[String] The ID of the wallet provider's application which is an optional input from the customer. This is required when the wallet provider supports several wallet applications.</td></tr><tr><td>TRANSACTION_HISTORY_CONNECTION_URL</td><td>[String] The URL for retrieving transaction history which is to be provided by Thales.</td></tr><tr><td>SECURE_LOG_LEVEL</td><td>[Number] Defines the level of logs to be written where <code>off = 0</code>, <code>fatal = 1</code>, <code>error = 2</code>, <code>warn = 3</code>, <code>info = 4</code>, and <code>debug = 5</code>.</td></tr><tr><td>DOMESTIC_CURRENCY_CODE</td><td>[Number] The domestic currency code configuration is provided according to ISO-4217 Standard numeric format. Please omit leading '0's in the currency code number. If not configured, default value is 978(Euro).</td></tr><tr><td>VISA_ONLINEPIN_PRIORITY</td><td>[Boolean] Configure Visa Online PIN Priority. If this is not configured, the SDK will process Visa tranasction with the CDCVM priority. For more information, refer to <a href="/pages/ZLsJ8UhfR5HYAlqIdNA5">Configure Visa CVM priority</a>.</td></tr></tbody></table>

</details>

You may define a custom name for the configuration PLIST file, for example: "YourPlistName.plist". The custom name may be provided via SDK initialisation.

By default, NFC Wallet SDK will search for `TSHPay.plist` in the main bundle of the application if the mobile application does not provide any.

The following examples shows how to initialise the SDK using the default TSHPay.plist

{% code lineNumbers="true" %}

```swift
Task {
    do {
        try await TSHPay.shared.configure(withVerificationMethod: .userPresence)
    } catch let error as TSHPaySDK.TSHPay.Error {
        switch error {
        case .storageUnrecoverableError:
            do {
                try await TSHPay.shared.reset()
                try await TSHPay.shared.configure(withVerificationMethod: .userPresence)
            } catch {
                // Handle the error.
            }
            
        default: break
            // Handle other errors.
        }
    }
}
```

{% endcode %}

### Check device eligibility

After SDK inititalization, verify the device eligibility to check:

* Device owner authentication method using `deviceEligibility`.
* Contactless payment capability using `contactlessPaymentEligibility`.

If the device meets the requirements, the SDK returns `supported`.

{% code lineNumbers="true" %}

```swift
func checkDeviceEligibility() {
    Task {
        let eligibility = await TSHPay.shared.deviceEligibility
        switch eligibility.deviceOwnerAuthentication {
        case .supported:
            // Device is eligible. You can start Tokenization.
        case .passcodeNotSet:
            // Ask the End User to set a device passcode.
        case .biometricNotSet:
            // Ask the End User to enroll biometrics (Touch ID / Face ID).
        }
    }
}
```

{% endcode %}

### Retrieving the Wallet ID <a href="#retrieving-the-wallet-id" id="retrieving-the-wallet-id"></a>

Use `TSHPay.walletID` to retrieve the wallet identifier.

The SDK generates the wallet ID the first time you call `TSHPay.configure`.

The wallet ID remains stable across application restarts.

If you reset the SDK, the wallet ID is regenerated.

Use the wallet ID for troubleshooting and support.

{% code lineNumbers="true" %}

```swift
let walletIdentifier = TSHPay.walletID
print("Retrieved wallet ID: \(walletIdentifier)")
```

{% endcode %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.payments.thalescloud.io/nfc-wallet-sdk-ios/get-started/configuration/3.-initialization.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
