ID Verification の Android SDK をアプリケーションに統合し、eKYC リモート本人確認を追加します。 サーバーサイドの Initialize API からトランザクション ID を取得し、それを SDK に渡して検証を開始します。
制限事項
スマートフォンおよびタブレットの Android 4.3 以降でサポートされています。
x86 デバイスはサポートされていません。
必要な権限
SDK は実行時に以下の権限を必要とします。
権限 | 必須 | 説明 |
android.permission.INTERNET | はい | ネットワークへのアクセスに必要です。 |
android.permission.ACCESS_NETWORK_STATE | いいえ (推奨) | |
android.permission.CAMERA | はい | 顔スキャンに必要です。Android 6.0 以降では実行時権限が必要です。 |
android.permission.WRITE_EXTERNAL_STORAGE | いいえ |
|
SDK のダウンロードと設定
AAR パッケージを「クライアント SDK リリースノート」からダウンロードします。Android デモをダウンロードして機能を試すこともできます。
AAR ファイルをプロジェクトの libs ディレクトリに展開し、これらの依存関係を build.gradle に追加します。
dependencies { // SDK モジュール implementation files('libs/idv-identityplatform-xxx.aar') implementation files('libs/idv-identityface-xxx.aar') implementation files('libs/idv-identitycrypto-xxx.aar') implementation files('libs/idv-identityocr-xxx.aar') implementation files('libs/Android-AliyunFaceGuard-xxx.aar') implementation files('libs/idv-identitybase-sdk-xxx.aar') implementation files('libs/idv-identityservice-sdk-xxx.aar') implementation files('libs/idv-identityquality-sdk-xxx.aar') implementation files('libs/idv-identityblink-sdk-xxx.aar') implementation files('libs/idv-identitymouth-sdk-xxx.aar') implementation files('libs/idv-identitymnn-xxx.aar') implementation files('libs/idv-identityocrservice-xxx.aar') implementation files('libs/idv-identitynfc-xxx.aar') implementation files('libs/IDOCR_PubSDK_Android-1.0.0.aar') // または、fileTree を使用して ID Verification SDK の AAR ファイルのディレクトリを指定します。 //implementation(fileTree(dir: "libs", includes: ["*.aar"])) implementation "androidx.appcompat:appcompat:1.5.0" implementation "androidx.activity:activity:1.7.0" implementation "androidx.recyclerview:recyclerview:1.0.0" implementation 'com.squareup.okhttp3:okhttp:4.9.3' implementation 'com.squareup.okio:okio:2.8.0' implementation 'com.aliyun.dpa:oss-android-sdk:2.9.21' implementation 'com.alibaba:fastjson:1.2.83_noneautotype' }説明xxxは SDK のバージョン番号です。すべてのサードパーティ依存関係を含めてください。含まれていない場合、SDK が正しく機能しない可能性があります。
tygerservice-xxx.aar はバージョン 1.3.4 で削除されました。
idv-identitymouth-sdk-xxx.aar はバージョン 1.3.6 で追加されました。
関連 API
SDK は、install、getMetaInfo、verify の 3 つの API を提供します。各 API について、以下で説明します。
SDK の初期化 (install)
関数プロトタイプ
public void install(Context context); public void install(Context context,Map<String, String> options);パラメーター
context:アプリケーションコンテキスト。
options パラメーターは、デフォルトでは
nullで、オプションのデータ収集設定を指定します。重要ID Verification クライアントには、デバイスヘルパーとして知られるセキュリティモジュールが組み込まれています。デバイスヘルパーは、現地のデータ収集コンプライアンス要件を満たすために、さまざまなデータ報告リージョンを提供します。ユーザーの属性に基づいて、
CustomUrlとCustomHostを設定して、異なる報告サイトを指定できます。アプリケーションセッションのライフサイクルごとに指定できるデータ報告リージョンは 1 つだけです。サーバー側のクエリのリージョンは、報告リージョンと一致する必要があります。サポートされるリージョンはプロダクトによって異なります。詳細については、「サポートされるリージョン」をご参照ください。
各リージョンの
CustomUrlは以下の通りです:中国 (香港):
https://cloudauth-device.cn-hongkong.aliyuncs.comシンガポール:
https://cloudauth-device.ap-southeast-1.aliyuncs.comインドネシア (ジャカルタ):
https://cloudauth-device.ap-southeast-5.aliyuncs.com米国 (シリコンバレー):
https://cloudauth-device.us-west-1.aliyuncs.comドイツ (フランクフルト):
https://cloudauth-device.eu-central-1.aliyuncs.comマレーシア (クアラルンプール):
https://cloudauth-device.ap-southeast-3.aliyuncs.com
パラメーター
説明
例
IPv6
デバイス情報を報告するために IPv6 ドメイン名を使用するかどうかを示します:
0 (デフォルト):いいえ (IPv4 ドメイン名を使用)
1:はい (IPv6 ドメイン名を使用)
"1"
DataSwitch
デバイス情報をいつ報告するかを制御します:
0 (デフォルト):SDK の初期化時
1:トークン取得時
説明デフォルト設定を推奨します。
"1"
CustomUrl
データ報告用のサーバードメイン名を設定します。
「各リージョンの CustomUrl」をご参照ください。
CustomHost
データ報告用のサーバーホストを設定します。
"cloudauth-device.ap-southeast-1.aliyuncs.com"
説明この例はシンガポールリージョン用です。他のリージョンのサーバーホストについては、「各リージョンの CustomUrl」をご参照ください。
戻り値:なし。
MetaInfo の取得 (getMetaInfo)
関数プロトタイプ
public static String getMetaInfo(Context context);パラメーター
名前
タイプ
説明
context
Context
アプリケーションコンテキスト。
戻り値:デバイスの環境情報を含む JSON 文字列。
{ "apdidToken": "", "appName": "com.aliyun.identity.platform", "appVersion": "1.0.1", "bioMetaInfo": "5.1.0:11501568,4", "deviceBrand": "xxx", "deviceManufacturer": "xxx", "deviceModel": "xxx", "deviceType": "android", "identityVer": "1.0.0", "osVersion": "10", "sdkVersion": "1.0.9" }
検証の開始 (verify)
verify を呼び出す前に、MetaInfo をサーバーに渡し、Initialize API からトランザクション ID を取得する必要があります。
新しいバージョンでは protocol フィールドが返されます。このフィールドを extParams で渡してください。
関数プロトタイプ
public void verify(String transactionId, Map<String, String> extParams, IdentityCallback callback);パラメーター
名前
タイプ
説明
transactionId
String
サーバーサイドの Initialize API から取得した transactionId。
重要各トランザクション ID は 1 回限り有効です。verify を呼び出すたびに、新しい ID を取得してください。
extParams
Map<String, String>
拡張パラメーター。不要な場合は null を渡します。
サポートされているフィールドについては、「extParams の設定に関する説明」をご参照ください。
callback
IdentityCallback
このコールバックは認証結果を返します。コールバック内のリターンコードの詳細については、「ネイティブ SDK クライアントのリターンコードとサブコード」をご参照ください。
コールバックの定義:
public class IdentityResponse { // 詳細は「リターンコード」を参照してください。 public int code; // 結果メッセージ。 public String message; } public interface IdentityCallback { boolean response(IdentityResponse response); }extParams の設定に関する説明
キー
説明
例 (String 型)
IdentityParams.OcrResultButtonColor
OCR 結果ページのボタンの色。
#FF0000
IdentityParams.RoundProgressColor
顔スキャン中の円の色。
#FF0000
IdentityParams.ShowAlbumIcon
OCR 中にアルバムアップロードのエントリーを表示します。
1 (デフォルト):表示
0:非表示
1
IdentityParams.ShowOcrResult
OCR 認識結果ページを表示します。
1 (デフォルト):表示
0:非表示
1
IdentityParams.EditOcrResult
OCR 結果ページを編集可能にするかどうかを設定します。
1 (デフォルト):編集可能
0:編集不可
1
IdentityParams.MaxErrorTimes
最大リトライ回数。
範囲: 3~10。デフォルト: 10。
10
IdentityParams.CardOcrTimeOutPeriod
OCR 認識のタイムアウト (秒)。
範囲: 20~60 秒。デフォルト: 20。
20
IdentityParams.FaceVerifyTimeOutPeriod
活性検知のタイムアウト (秒)。
範囲: 20~60 秒。デフォルト: 20。
20
IdentityParams.OcrResultTimeOutPeriod
OCR 結果ページの編集タイムアウト (秒)。
デフォルト: 無制限。
60
IdentityParams.SdkLanguage
SDK の表示言語をカスタマイズできます。デフォルトでは、SDK はモバイルデバイスのシステム言語を使用します。
説明サポートされている言語の一覧については、「Android および iOS SDK の言語のカスタマイズ」をご参照ください。
zh-Hans
IdentityParams.CloseButtonLayout
閉じるボタンのレイアウトを指定します。
left (デフォルト):左側
right:右側
left
IdentityParams.WaterMark
OCR 成功後に表示されるウォーターマークテキスト。
テスト用のウォーターマークテキスト
IdentityParams.Protocol
サーバーサイドの Initialize API レスポンスから取得したプロトコル文字列。
説明サーバーサイドの Initialize API レスポンスから protocol 値を渡すことで、内部 API 呼び出しが削減され、パフォーマンスが向上します。
なし
リターンコード
詳細については、「ネイティブ SDK クライアントのリターンコードとサブコード」をご参照ください。
サンプルコード
public class MainActivity extends AppCompatActivity {
private String transactionId = "";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// SDK を初期化
IdentityPlatform.getInstance().install(MainActivity.this);
// MetaInfo を取得
String metaInfo = IdentityPlatform.getMetaInfo(MainActivity.this);
/**
* MetaInfo をアプリケーションサーバーに送信し、クラウド側の Initialize API を呼び出して transactionId を取得します。
* 新しいバージョンではプロトコルデータも返されます。
*/
// transactionId = getTransactionIdFromServer(metaInfo).transactionId;
// protocol = getTransactionIdFromServer(metaInfo).protocol;
Map<String, String> extParams = new HashMap();
// プロトコルデータを設定
extParams.put(IdentityParams.PROTOCOL, protocol);
// SDK の言語を設定
extParams.put(IdentityParams.SdkLanguage, "en");
// 検証を開始
IdentityPlatform.getInstance().verify(transactionId, extParams,
new IdentityCallback() {
@Override
public boolean response(final IdentityResponse response) {
if (IdentityResponseCode.IDENTITY_SUCCESS == response.code) {
Toast.makeText(MainActivity.this,
"検証に成功しました", Toast.LENGTH_LONG).show();
} else {
Toast.makeText(MainActivity.this,
"検証に失敗しました([" + response.code + "]" +
response.message + ")",
Toast.LENGTH_LONG).show();
}
return true;
}
});
}
}難読化ルール
-verbose
-keep class com.idv.identity.platform.api.** {*;}
-keep class com.idv.identity.platform.log.** {*;}
-keep class com.idv.identity.util.IdentityUtils {*;}
-keep class com.idv.identity.ocr.IdentityOcrApi {*;}
-keep class com.idv.identity.platform.model.** {*;}
-keep class com.idv.identity.platform.config.** {*;}
-keep class com.idv.identity.face.IdentityFaceApi {*;}
-keep class com.face.verify.intl.** {*;}
-keep class com.alibaba.fastjson.** {*;}
-keep class face.security.device.api.** {*;}
-keep class net.security.device.api.** {*;}
-keep class com.dtf.toyger.** { *; }
-dontwarn net.security.device.api.**
-dontwarn face.security.device.api.**
-keep class com.idv.identity.service.algorithm.** {*;}
-keep class com.idv.identity.base.algorithm.** {*;}
-keep class com.idv.identity.quality.QualityRouter {*;}
-keep class com.idv.identity.blink.BlinkRouter {*;}
-keep class com.idv.identity.service.IdentityFaceService {*;}
-keep class com.idv.identity.service.ocr.IdentityDocService {*;}
-keep class com.idv.identity.mouth.MouthRouter {*;}
-keep class com.alibaba.sdk.android.oss.** { *; }
-dontwarn okio.**
-dontwarn org.apache.commons.codec.binary.**
# NFC
-keep class com.idv.identity.nfc.IdentityNfcApi { *; }
-keep class org.jmrtd.** {*;}
-keep class net.sf.**{*;}
-keep class org.**{*;}
-keep class cn.**{*;}
# 警告を抑制するため、これらのルールを既存のkeepルールに追加してください。
# これはAndroid Gradleプラグインによって自動的に生成されます。
-dontwarn com.fasterxml.**
-dontwarn com.google.**
-dontwarn java.applet.Applet
-dontwarn java.awt.**
-dontwarn javax.**
-dontwarn org.**
-dontwarn retrofit2.**
-dontwarn springfox.documentation.spring.web.json.Json
# ログの難読化 (オプション)
-assumenosideeffects class android.util.Log {
public static *** d(...);
}
# 1.3.2より前のバージョンを使用している場合は、次の難読化ルールを追加してください。
-keepattributes Signature
-keepattributes *Annotation*
-keep class com.alibaba.fastjson.** { *; }
-keep class * extends com.alibaba.fastjson.TypeReference { *; }コンポーネントのトリミング
SDK の統合フェーズで一部のコンポーネントをトリミングできます。SDK パッケージのサイズを最小限に抑えるには、製品で必要なコンポーネントのみを統合してください。これにより、完全な機能セットとセキュリティコンプライアンスを確保できます。トリミングの詳細なルールについては、「SDK の軽量化手順」をご参照ください。