> 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/set-cdcvm-method.md).

# CDCVM 方法を設定する

## 概要

デジタルカードプロファイルは、CDCVMをサポートするかどうかを定義します。

特定のウォレットインスタンスでは、 **CDCVMをサポートする最初に登録されたカード** が **CDCVM方式** を定義し、 **デジタルウォレットアプリケーション**.

NFC Wallet SDKでは、異なるCDCVM方式を持つカードを同一のウォレットインスタンス内で共存させることはできません。

で説明されているように [CDCVMの処理](/nfc-wallet-sdk-android/ja/implement-nfc-wallet/handle-cdcvm.md)、ほとんどのNFC WalletプログラムはCDCVMを使用します。

このセクションでは、 **トークン化** 中に、CDCVMをサポートする最初のカードについて、デバイスの機能に基づいてCDCVM方式を設定します。

{% hint style="danger" %}
**CDCVM方式の設定は必須です**

プロファイルがCDCVMをサポートしており、CDCVM方式を設定しない場合：

* カード一覧の取得は失敗し、 `DigitalizedCardErrorCodes.CD_CVM_REQUIRED`.
* CDCVM方式を設定するまでNFC決済は失敗します。
  {% endhint %}

## SDK統合

### CDCVMがサポートされているか確認し、設定する

使用 `CHVerificationManager` を使用して、CDCVMがサポートされているか、および現在のウォレットインスタンスで既に設定されているかを確認します：

* `CHVerificationManager.isFCDCVMSupported()` はCDCVMがサポートされているかを確認します。
* `CHVerificationManager.isFCdCvmSet()` はCDCVM方式がすでに設定されているかを確認します。
* `CHVerificationManager.getDefaultFCdCvm()` はデジタルウォレットアプリケーションで使用されるCDCVM方式を返します。

CDCVMがサポートされていて未設定の場合は、で説明されているように初期化します。 [CDCVM方式を設定する](#set-the-cdcvm-method).

### 処理 `CD_CVM_REQUIRED` カード一覧を取得するとき

CDCVM方式を設定せずに、 `DigitalizedCardManager.getAllCards()`を使用してカード一覧を取得すると、SDKは `DigitalizedCardErrorCodes.CD_CVM_REQUIRED`を返すことがあります。その場合は、で説明されているようにCDCVM方式を初期化します。 [CDCVM方式を設定する](#set-the-cdcvm-method).

```java
DigitalizedCardManager.getAllCards( new AbstractAsyncHandler<String[]> () {
    
    @Override
    public void onComplete(final AsyncResult<String[]> asyncResult) {
        if (asyncResult.isSuccessful()) {
            // カード一覧の取得に成功しました
        }
        else {
            // カード一覧の取得に失敗しました
            final int errorCode = asyncResult.getErrorCode();
            if (errorCode == DigitalizedCardErrorCodes.CD_CVM_REQUIRED) {
                // ここでCDCVM方式を設定します（次のセクションを参照）
                // ....
            }
        }
    }
    
});
```

### CDCVM方式を設定する

使用 `DeviceCVMManager.initialize(...)` を使用して、デバイスの機能に応じてCDCVM方式を設定します：

* **生体認証**: `CHVerificationMethod.BIOMETRICS`
* **デバイス認証情報（キーガード）**: `CHVerificationMethod.DEVICE_KEYGUARD`

{% hint style="info" %}
CDCVM方式を設定した後、エンドユーザーがデバイスのロック解除方法を変更するシナリオを考慮してください。参照してください。 [デバイスのロック解除方法更新シナリオ](/nfc-wallet-sdk-android/ja/implement-nfc-wallet/tokenize-a-card/set-cdcvm-method/device-unlock-method-update-scenarios.md).
{% endhint %}

#### 実装例

```java
// CDCVMのデバイス有効性を確認
DeviceCVMEligibilityResult result =
        DeviceCVMEligibilityChecker.checkDeviceEligibility(getApplicationContext());

if (result.getBiometricsSupport() == BiometricsSupport.SUPPORTED) {
    // 生体認証がサポートされています
    try {
        DeviceCVMManager.INSTANCE.initialize(CHVerificationMethod.BIOMETRICS);
    } catch (DeviceCVMException e) {
        // エラーを処理
    }
}
else if (result.getDeviceKeyguardSupport() == DeviceKeyguardSupport.SUPPORTED) {
    // 生体認証がサポートされていない場合は、デバイスのキーガードを使用します。
    try {
        DeviceCVMManager.INSTANCE.initialize(CHVerificationMethod.DEVICE_KEYGUARD);
    } catch (DeviceCVMException e) {
        // エラーを処理
    }
}
else {
    // デバイスがCDCVMをサポートしていない、またはエンドユーザーが安全なロック画面を有効にしていません。
    // エンドユーザーに生体認証またはデバイス認証情報を有効にするよう促します。
}
```


---

# 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/set-cdcvm-method.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.
