> 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 %}

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

次を使用できます `TSHPay.configure` API を使用して SDK を初期化します。wallet では、次の 2 つのパラメーターを提供する必要があります。

* カード所有者の検証方式 (CVM)
* Configuration PLIST ファイル

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

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

wallet は、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] wallet プロバイダーの ID です。</td></tr><tr><td>MG_WALLET_APPLICATION_ID</td><td>[String] wallet プロバイダーのアプリケーションの ID です。これは顧客からの任意入力です。wallet プロバイダーが複数の wallet アプリケーションをサポートしている場合に必要です。</td></tr><tr><td>TRANSACTION_HISTORY_CONNECTION_URL</td><td>[String] Thales から提供される取引履歴取得用の URL です。</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>[数値] 国内通貨コードの設定は、ISO-4217 標準の数値形式に従って指定されます。通貨コード番号の先頭の「0」は省略してください。設定されていない場合の既定値は 978（ユーロ）です。</td></tr><tr><td>VISA_ONLINEPIN_PRIORITY</td><td>[ブール値] Visa Online PIN の優先順位を設定します。これが設定されていない場合、SDK は CDCVM の優先順位で Visa トランザクションを処理します。詳細については、以下を参照してください <a href="/pages/26a13a1d1a6fb065d1be3a5eeaa088242ff1931c">Visa の CVM 優先順位を設定する</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 の初期化後、次を確認するためにデバイスの有効性を確認してください:

* 使用するデバイス所有者の認証方法 `デバイスの適格性`.
* を使用した非接触決済機能 `非接触決済の利用資格`.

デバイスが要件を満たしている場合、SDK は返します `サポート済み`.

{% code lineNumbers="true" %}

```swift
func checkDeviceEligibility() {
    Task {
        let 有効性 = await TSHPay.shared.device有効性
        switch 有効性.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("取得したウォレット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, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
