> 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-android/ja/implement-nfc-wallet/tokenize-a-card/trigger-provisioning.md).

# プロビジョニングをトリガーする

## 概要

カードをデジタル化したら、デジタルカードをプロビジョニングするためにプロビジョニングセッションを開始します。

プロビジョニングセッション中、 **NFCウォレット** はデジタルカードプロファイルと支払い鍵を安全にプロビジョニングします **デジタルウォレットアプリケーション**.

activationCodeを受け取った直後にプロビジョニングセッションを開始してください。 `activationCode` から `MGDigitizationListener.onCPSActivationCodeAcquired`. ご覧ください [カードをデジタル化する](/nfc-wallet-sdk-android/ja/implement-nfc-wallet/tokenize-a-card/digitize-a-card.md#sdk-integration).

このコールバックはまた次を返します `digitalCardId`。後続の操作（例えば、アクセストークン、取引履歴、ライフサイクル管理）用に保存してください。セキュアプロビジョニングを開始するためにこれを必ずしも必要とするわけではありません。

{% hint style="info" %}
このステップはまた、間のセキュアチャネルを設定します。 **NFCウォレットSDK** と **NFCウォレットバックエンド**.

この設定は次のように呼ばれます **デバイス登録** （別名 **CPS登録**).
{% endhint %}

## シーケンス図

<figure><img src="/files/e7ecae58a8e3f094140294df14a07ec417c21acb" alt=""><figcaption><p>セキュアプロビジョニングフロー（デバイス登録とプロビジョニングセッション）。</p></figcaption></figure>

## SDK統合

セキュアプロビジョニングには次が必要です **デバイス登録**.

デバイス登録は通常、デバイス上のウォレットインスタンスごとに一度必要です。登録が必要な場合、登録フローは自動的にプロビジョニングセッションをトリガーします。

デバイス登録が既に完了している場合は、を呼び出してプロビジョニングセッションを開始します `ProvisioningBusinessService.sendActivationCode(...)`.

SDKはを要求します `activationCode` を通じて `EnrollingServiceListener.onCodeRequired(...)`。その時点で値を提供してください。

### 前提条件

開始する前に、次を確認してください:

* を初期化しました **NFCウォレットSDK**. ご覧ください [NFCウォレットSDKを初期化する](/nfc-wallet-sdk-android/ja/get-started/configuration/4.-initialize-the-nfc-wallet-sdk.md).
* プッシュ通知を構成し、プッシュトークンを取得しました。参照： [プッシュ通知](/nfc-wallet-sdk-android/ja/get-started/configuration/5.-push-notifications.md).
* を受け取りました `activationCode` デジタル化から。参照： [カードをデジタル化する](/nfc-wallet-sdk-android/ja/implement-nfc-wallet/tokenize-a-card/digitize-a-card.md#sdk-integration).

### デバイス登録

デバイス登録には次の入力が必要です:

* `activationCode` (`byte[]`): デジタル化によって返されます。
* `walletId`: 次を使用して取得します `MGCardEnrollmentService.getWalletId()`。この値をとして渡してください `userId` パラメータに `EnrollingBusinessService.enroll(...)`. ご覧ください [ウォレットIDを取得する](/nfc-wallet-sdk-android/ja/get-started/configuration/4.-initialize-the-nfc-wallet-sdk.md#retrieving-the-wallet-id).
* `pushToken`: のプッシュトークン **FCM** または **HMS Push Kit**.

{% hint style="warning" %}
接頭辞 **HMS Push Kit** でトークンに付けてください `HMS:` （例えば、 `HMS:<token>`).
{% endhint %}

### デバイス登録状況を確認する

EnrollingBusinessService.isEnrolled() を使ってデバイス登録状況を確認します `EnrollingBusinessService.isEnrolled()`.

このステータスは、現在のデバイス上のウォレットインスタンスに対してセキュアチャネルが既に確立されているかを示します。

これはを返します `EnrollmentStatus`:

* `ENROLLMENT_NEEDED`: を呼び出してください `EnrollingBusinessService.enroll(...)`.
* `ENROLLMENT_IN_PROGRESS`: を呼び出してください `EnrollingBusinessService.continueEnrollment(...)`.
* `ENROLLMENT_COMPLETE`: を呼び出してください `ProvisioningBusinessService.sendActivationCode(...)`.

### を実装してください `EnrollingServiceListener`

を実装してください `EnrollingServiceListener` で登録フローを進めます:

* `onCodeRequired`: を提供してください `activationCode`.
* `onComplete`: デバイス登録が正常に完了しました。
* `onError`: エラーを次で処理します `ProvisioningServiceError`.

<pre class="language-java" data-title="MyEnrollingServiceListener.java"><code class="lang-java"><strong>public class MyEnrollingServiceListener implements EnrollingServiceListener {
</strong>
    // MGDigitizationListener.onCPSActivationCodeAcquired(...) から受け取る
    private final byte[] activationCode;

    public MyEnrollingServiceListener(final byte[] activationCode) {
        this.activationCode = activationCode;
    }

    @Override
    public void onStarted() {
        // 登録フローが開始されたときに呼ばれます。
    }

    @Override
    public void onCodeRequired(final CHCodeVerifier chCodeVerifier) {
        // フローを続行するためにアクティベーションコードが必要なときに呼ばれます。
        final SecureCodeInputer inputer = chCodeVerifier.getSecureCodeInputer();
        for (final byte b : activationCode) {
            inputer.input(b);
        }
        }
    }

    @Override
    inputer.finish();
        public void onComplete() {
        // デバイス登録が正常に完了したときに一度呼ばれます。
    }

    @Override
    // グリーンフローでは、通常これがプロビジョニング完了を意味します。
        public void onError(final ProvisioningServiceError error) {
        // デバイス登録が失敗したときに呼ばれます。
    }
}
</code></pre>

### // error.getCode() を解析し、適切な再試行/復旧ロジックを適用してください。

```java
デバイス登録コードの実装
byte[] activationCode = ...; // MGDigitizationListener.onCPSActivationCodeAcquired(...) から
String pushToken = "..."; // FCM または HMS Push Kit から

String language = "en"; // 可能であればアプリのロケールを使用してください。
// ウォレットIDはデバイス登録のためのユーザー識別子です。

String walletId = MobileGatewayManager.INSTANCE.getCardEnrollmentService().getWalletId();

EnrollingServiceListener enrollingListener = new MyEnrollingServiceListener(activationCode);
final EnrollingBusinessService enrollingService = ProvisioningServiceManager.getEnrollingBusinessService();

final ProvisioningBusinessService provisioningBusinessService = ProvisioningServiceManager.getProvisioningBusinessService();
// 登録状況を確認します。
final EnrollmentStatus status = enrollingService.isEnrolled();
    switch (status) {
        case ENROLLMENT_NEEDED:
        // このウォレットインスタンスでの最初のデバイス登録試行です。
        enrollingService.enroll(walletId, pushToken, language, enrollingListener);
    
    break;
        case ENROLLMENT_IN_PROGRESS:
        // 登録は以前に開始されており、再開する必要があります。
        enrollingService.enroll(walletId, pushToken, language, enrollingListener);
    
    enrollingService.continueEnrollment(language, enrollingListener);
        case ENROLLMENT_COMPLETE:
        // デバイス登録はすでに完了しています。
        // このカードのプロビジョニングをトリガーします。
        // SDK は enrollingListener.onCodeRequired(...) を介してアクティベーションコードを要求します。
        enrollingService.enroll(walletId, pushToken, language, enrollingListener);
    
    provisioningBusinessService.sendActivationCode(enrollingListener);
        default:','t133':'// エラーをログに記録します（不明なステータス）。'}
 }

```


---

# 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-android/ja/implement-nfc-wallet/tokenize-a-card/trigger-provisioning.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.
