ドキュメントキャプチャ
本人確認書類のキャプチャ。SDK はドキュメントの位置決めを補助するフレームを表示し、位置が合ったらユーザーがボタンをクリックして写真を撮影します。
コンテンツ検証なし
SDK はキャプチャされているものに対して何らかの検証を行いません。
利用可能なドキュメントフレーム
| フレーム | 説明 |
|---|---|
DocumentEnums.CPF | CPF をキャプチャ |
DocumentEnums.CNH | 開いた CNH をキャプチャ |
DocumentEnums.cnhFrente | CNH の表面をキャプチャ |
DocumentEnums.cnhVerso | CNH の裏面をキャプチャ |
DocumentEnums.RG | 開いた RG をキャプチャ |
DocumentEnums.rgFrente | RG の表面をキャプチャ |
DocumentEnums.rgVerso | RG の裏面をキャプチャ |
DocumentEnums.none | その他のドキュメント用汎用長方形フレーム |
汎用フレーム
特定のフレームが存在しないドキュメント(例:RNE)をキャプチャする必要がある場合は、DocumentEnums.none を使用してください — どのキャプチャにも対応できる汎用の長方形フレームです。
サポートされているドキュメントタイプの一覧については、API リファレンス > Enum をご参照ください。
ドキュメントキャプチャの開始
ステップ 1 — AcessoBioManagerDelegate を実装する
AcessoBioManagerDelegate は SDK のライフサイクルコールバックを処理します。4 つの必須メソッドを実装してください:
| メソッド | 呼び出しタイミング |
|---|---|
onErrorAcessoBioManager(error) | SDK 操作中にエラーが発生した場合 |
onUserClosedCameraManually() | ユーザーが手動でカメラを閉じた場合 |
onSystemClosedCameraTimeoutSession() | 40 秒のセッション制限に達した場合 |
onSystemChangedTypeCameraTimeoutFaceInference() | 13 秒間顔が検出されなかった場合 — 手動キャプチャに切り替わりま す |
- Swift
- Objective-C
class ViewController: UIViewController, AcessoBioManagerDelegate {
var unicoCheck: AcessoBioManager!
override func viewDidLoad() {
super.viewDidLoad()
unicoCheck = AcessoBioManager(viewController: self)
}
func onErrorAcessoBioManager(_ error: ErrorBio!) { }
func onUserClosedCameraManually() { }
func onSystemClosedCameraTimeoutSession() { }
func onSystemChangedTypeCameraTimeoutFaceInference() { }
}
@implementation ViewController: UIViewController
- (void)viewDidLoad {
[super viewDidLoad];
unicoCheck = [[AcessoBioManager alloc]initWithViewController:self];
}
- (void)onErrorAcessoBioManager:(ErrorBio *)error { }
- (void)onSystemChangedTypeCameraTimeoutFaceInference { }
- (void)onSystemClosedCameraTimeoutSession { }
- (void)onUserClosedCameraManually { }
@end
必須デリゲートメソッド
上記の 4 つのデリゲートメソッドは、ロジックがなくてもプロジェクトに作成する必要があります。作成しない場合、プロジェクトは正常にコンパイルされません。
ステップ 2 — DocumentCameraDelegate と AcessoBioDocumentDelegate を実装する
これらのデリゲートはドキュメントキャプチャの結果コールバックを処理します:
| メソッド | 説明 |
|---|---|
onSuccessDocument(result) | キャプチャ成功 — base64(プレビュー)と encrypted(API 用 JWT)を含む DocumentResult を返す |
onErrorDocument(errorBio) | キャプチャ失敗 — コードと説明を含む ErrorBio を返す |
- Swift
- Objective-C
class ViewController: UIViewController, AcessoBioManagerDelegate,
DocumentCameraDelegate, AcessoBioDocumentDelegate {
func onSuccessDocument(_ result: DocumentResult!) { }
func onErrorDocument(_ errorBio: ErrorBio!) { }
}
// .h
@interface ViewController: UIViewController <AcessoBioManagerDelegate,
DocumentCameraDelegate, AcessoBioDocumentDelegate> {
AcessoBioManager *unicoCheck;
}
// .m
- (void)onSuccessDocument:(DocumentResult *)result {
NSLog(@"%@", result.base64);
}
- (void)onErrorDocument:(ErrorBio *)errorBio { }
ステップ 3 — prepareDocumentCamera と openDocument を呼び出す
SDK 設定を渡して prepareDocumentCamera を呼び出します。カメラの準備が整うと、onCameraReadyDocument が AcessoBioCameraOpenerDelegate とともにトリガーされます — openDocument() を使用してカメラを開き、希望する DocumentEnums を渡します:
onCameraReadyDocument(cameraOpener)— カメラの準備完了;openDocument(.CNH, delegate: self)を呼び出す。onCameraFailedDocument(message)— カメラの準備失敗(ErrorPrepareはErrorBioの拡張)。
- Swift
- Objective-C
@IBAction func openCamera(_ sender: Any) {
unicoCheck.build().prepareDocumentCamera(self, config: YourUnicoConfigClass())
}
func onCameraReadyDocument(_ cameraOpener: AcessoBioCameraOpenerDelegate!) {
cameraOpener.openDocument(DocumentEnums.CNH, delegate: self)
}
func onCameraFailedDocument(_ message: ErrorPrepare!) { }
- (IBAction)openCamera:(UIButton *)sender {
[[unicoCheck build] prepareDocumentCamera:self config:[YourUnicoConfigClass new]];
}
- (void)onCameraReadyDocument:(id)cameraOpener {
[cameraOpener openDocument:DocumentCNH delegate:self];
}
- (void)onCameraFailedDocument:(ErrorPrepare *)message { }
結果の完全な処理については、結果の受け取り をご参照ください。