> 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/implement-nfc-wallet/enroll-wallet.md).

# ウォレットを登録する

## 概要

登録する **デジタルウォレットアプリケーション** 後に **NFC Wallet SDK** 初期化後、開始前に **トークン化**。ウォレット登録は、デジタルウォレットアプリケーションに、呼び出しに必要なセキュリティ資産を提供します **NFCウォレット** サービス:

* これはウォレットインスタンスごとに1回だけ実行します。
* デジタルウォレットアプリケーションが **NFCウォレット** サービスを使用している場合にのみ実行します。
* これは非接触決済をサポートするデバイスでのみ実行します。参照: [非接触対応を確認する](/nfc-wallet-sdk-ios/ja/implement-nfc-wallet/check-contactless-capability.md).

{% hint style="warning" %}
〜を使用するデジタルウォレットアプリケーションのみを登録してください **NFCウォレット** サービスを使用している場合にのみ実行します。

これにより、デジタルウォレットアプリケーションからの不要なネットワークトラフィックと、 **NFCウォレット** 製品への不要な負荷を回避できます。
{% endhint %}

## シーケンス図

ウォレットアプリケーションを登録するための高レベルなフロー。

<figure><img src="/files/d230931d1b5a909a514fece6653c7d8e432c431b" alt=""><figcaption><p>ウォレット登録フロー。</p></figcaption></figure>

{% hint style="info" %}
このフローの技術的な名称は **ウォレットのセキュア登録** で **NFCウォレット**.
{% endhint %}

## SDK統合

### 前提条件

開始前に、以下を確認してください:

* デジタルウォレットアプリケーションが **NFCウォレット** バックエンドにオンボーディングされている。
* 〜を初期化した **NFC Wallet SDK**.
* ウォレットは登録されていない（`WalletSecureEnrollmentService.isEnrolled()` を返す `false`).
* 非接触決済をサポートする場合は、デバイスが対象であることを確認してください。参照: [非接触対応を確認する](/nfc-wallet-sdk-ios/ja/implement-nfc-wallet/check-contactless-capability.md).

{% hint style="info" %}
デジタルウォレットアプリケーションが非接触決済をサポートしない場合は、非接触機能のチェックをスキップします（たとえば、QRコードのみ、またはDSRPリモート決済のみの場合）。
{% endhint %}

### ウォレット登録を実行する

ウォレット登録は、デジタルウォレットアプリケーションのライフサイクルにおける一度きりの操作です。

SDK初期化後に実行し、ウォレットが未登録の場合のみ行います。

1. 次を `WalletSecureEnrollmentService` インスタンスを作成します。
2. 確認 `wse.isEnrolled()`.
3. 必要に応じて、次を呼び出します: `wse.enroll()` して処理を開始します。操作が成功すると、ウォレットの安全な登録は完了します。失敗した場合はエラーがスローされます。

ウォレットの安全な登録が正常に完了したら、次へ進みます: [カードをトークン化する](/nfc-wallet-sdk-ios/ja/implement-nfc-wallet/tokenize-a-card.md).

```swift
func invokeWSEAsync() async {
   do {
        let wse = try WalletSecureEnrollmentService()
        // ウォレットの登録状態を確認します。
        if wse.isEnrolled() {
            // WSEは登録済み
        } else {
            // ウォレットの安全な登録を開始します。
            try await wse.enroll()
            // ここで登録処理が正常に完了します。
        }
    } catch {
        // WSEエラー 
    }
}
```

### エラー

ウォレット登録に失敗した場合は、次のエラー種別を処理してください:

* `clientError`: SDK内部エラー。メッセージがデジタルウォレットアプリケーションに提供されます。
* `serverError`: バックエンドエラー。メッセージ、 `httpStatus`, `errorCode`、および任意の `additionalInfo` がデジタルウォレットアプリケーションに提供されます。
* `networkError`: デバイスにインターネット接続がありません。

{% hint style="info" %}
この `WalletSecureEnrollmentService.eventStream` と `WalletSecureEnrollmentService.State` APIは非推奨であり、次のリリースで削除されます。そのため、コードを移行して次を使用する必要があります: `WalletSecureEnrollmentService.enroll` API、および上記で示したすべての新しい実装で
{% endhint %}

### 非推奨のAPI

以下の例は、次の使用方法を示します: `WalletSecureEnrollmentService.State` と `WalletSecureEnrollmentService.eventStream` 非推奨のAPIです。

次は、 `WalletSecureEnrollment` のときに `WalletSecureEnrollmentService.eventStream` （非推奨）APIが使用される場合:

* `.started`: ウォレットの安全な登録プロセスが開始されます。
* `.completed` : ウォレットの安全な登録プロセスが完了します。
* `.errorEncountered`: ウォレットの安全な登録エラーが返されます。

```swift
// 非推奨API
func invokeWSEAsync() async {
    do {
        let wse = try WalletSecureEnrollmentService()
        // ウォレットの登録状態を確認します。
        if wse.isEnrolled() {
            // WSEは登録済み
        } else {
          // ウォレットの安全な登録を開始します。
            wse.enroll()
            for await state in wse.eventStream {
              switch state {
                case .started:
                  // WSE開始時にトリガーします。
                case .completed:
                  // WSE完了時にトリガーします。
                case .errorEncountered(let error):
                  switch error {
                    case .clientError(let message):
                        // エラー処理 
                    case .serverError(let message, let httpStatus, let errorCode, let additionalInfo):
                        // エラー処理 
                    case .networkError:
                        // エラー処理 
                    }
                }
            }
        }
    } catch {
        // WSE初期化エラー 
    }
}
```


---

# 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/implement-nfc-wallet/enroll-wallet.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.
