> 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/ja/get-started/configuration/3.-initialization.md).

# 3. 初期化

## NFC Wallet SDK の初期化 <a href="#tsh-pay-sdk-initialisation" id="tsh-pay-sdk-initialisation"></a>

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

NFC Wallet SDK は iCloud およびデバイスのバックアップ復元機能をサポートしていません。
{% endhint %}

NFC Wallet SDK の機能を使用する前に、デジタルウォレットアプリケーション（ウォレット）で SDK を初期化する必要があります。

次を使用できます `TSHPay.configure` SDK を初期化する API。ウォレットは 2 つのパラメータを提供する必要があります:

* カード所有者認証方法（CVM）
* 構成 PLIST ファイル

SDK の初期化は、アプリケーションが起動されるたびに実行する必要があります。

### カード所有者認証方法 <a href="#cardholder-verification-method" id="cardholder-verification-method"></a>

ウォレットは、SDK 初期化時に認証方法を提供する必要があります。次の認証方法のいずれかが選択されます:

* `.userPresence` : デバイスのパスコードをフォールバックとして使用する生体認証（TouchID/FaceID）を用いた認証方法、またはカードのデジタル化プロセス後に生体認証が削除された場合にデバイスのパスコードを使用する方法です。MPA は、支払い確認ステップで認証方法を生体認証またはデバイスのパスコードに変更できます。
* `biometricOnly` :TouchID/FaceID のみを使用する認証方法です。

カード所有者認証方法の詳細については、API ドキュメントを参照してください。

### PLIST ファイルの構成 <a href="#configuration-plist-file" id="configuration-plist-file"></a>

PLIST ファイルを作成し、モバイルアプリケーションのメインバンドルに保存する必要があります。

**TSHPay.plist**

<details>

<summary>TSHPay.plist パラメータの説明</summary>

<table><thead><tr><th width="374">キー</th><th>コメント</th></tr></thead><tbody><tr><td>REALM</td><td>[String] 固定パラメータです。たとえば、「CBP」です。</td></tr><tr><td>OAUTH_CONSUMER_KEY</td><td>[String] Thales により提供される Consumer Key です。</td></tr><tr><td>GATEWAY_URL</td><td>[String] Thales により提供される Rages の URL です。</td></tr><tr><td>CSR_DOMAIN</td><td>[String] HTTPS 呼び出しを保護するコンポーネント内の証明書署名要求に使用されます。設定する値については、Thales のインテグレーターにお問い合わせください。</td></tr><tr><td>CSR_EMAIL</td><td>[String] 会社のメールアドレスです。</td></tr><tr><td>CPS_URL</td><td>[String] Thales のインテグレーターにより提供される CPS サーバーの URL です。</td></tr><tr><td>MG_CONNECTION_URL</td><td>[String] Thales により提供される MG サーバーの URL です。</td></tr><tr><td>MG_WALLET_PROVIDER_ID</td><td>[String] ウォレットプロバイダーの ID です。</td></tr><tr><td>MG_WALLET_APPLICATION_ID</td><td>[String] ウォレットプロバイダーのアプリケーションの ID で、顧客からの任意入力です。これは、ウォレットプロバイダーが複数のウォレットアプリケーションをサポートしている場合に必要です。</td></tr><tr><td>TRANSACTION_HISTORY_CONNECTION_URL</td><td>[String] 取引履歴を取得するための URL で、Thales により提供されます。</td></tr><tr><td>SECURE_LOG_LEVEL</td><td>[Number] 書き込むログのレベルを定義します。 <code>off = 0</code>, <code>fatal = 1</code>, <code>error = 2</code>, <code>warn = 3</code>, <code>info = 4</code>、および <code>debug = 5</code>.</td></tr><tr><td>DOMESTIC_CURRENCY_CODE</td><td>[Number] 国内通貨コードの構成は、ISO-4217 標準の数値形式に従って提供されます。通貨コード番号の先頭の「0」は省略してください。設定されていない場合、デフォルト値は 978（ユーロ）です。</td></tr><tr><td>VISA_ONLINEPIN_PRIORITY</td><td>[Boolean] Visa Online PIN Priority を構成します。これが設定されていない場合、SDK は CDCVM 優先で Visa トランザクションを処理します。詳細は、 <a href="/pages/26a13a1d1a6fb065d1be3a5eeaa088242ff1931c">Visa CVM priority の構成</a>.</td></tr></tbody></table>

</details>

構成 PLIST ファイルには、たとえば「YourPlistName.plist」のようにカスタム名を定義できます。カスタム名は SDK 初期化時に指定できます。

デフォルトでは、NFC Wallet SDK は `TSHPay.plist` を、モバイルアプリケーションから指定がない場合にアプリケーションのメインバンドル内で検索します。

以下の例は、デフォルトの TSHPay.plist を使用して SDK を初期化する方法を示しています

{% 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 {
                // エラーを処理します。
            }
            
        default: break
            // 他のエラーを処理します。
        }
    }
}
```

{% endcode %}

### デバイスの有効性を確認

SDK の初期化後、デバイスの有効性を確認して以下をチェックします:

* 次を使用するデバイス所有者認証方法 `deviceEligibility`.
* 次を使用する非接触決済機能 `contactlessPaymentEligibility`.

デバイスが要件を満たしている場合、SDK は次を返します `supported`.

{% code lineNumbers="true" %}

```swift
func checkDeviceEligibility() {
    Task {
        let eligibility = await TSHPay.shared.deviceEligibility
        switch eligibility.deviceOwnerAuthentication {
        case .supported:
            // デバイスは有効です。トークン化を開始できます。
        case .passcodeNotSet:
            // エンドユーザーにデバイスのパスコード設定を促します。
        case .biometricNotSet:
            // エンドユーザーに生体認証（Touch ID / Face ID）の登録を促します。
        }
    }
}
```

{% endcode %}

### ウォレット ID の取得 <a href="#retrieving-the-wallet-id" id="retrieving-the-wallet-id"></a>

次を使用します `TSHPay.walletID` ウォレット識別子を取得します。

SDK は、初めて次を呼び出したときにウォレット ID を生成します `TSHPay.configure`.

ウォレット ID はアプリケーションの再起動後も保持されます。

SDK をリセットすると、ウォレット ID は再生成されます。

トラブルシューティングとサポートにはウォレット ID を使用してください。

{% 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/ja/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.
