文件采集
采集身份证件。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 参考 > 枚举。
开始文件采集
步骤 1 — 实现 AcessoBioManagerDelegate
AcessoBioManagerDelegate 负责处理 SDK 生命周期回调。实现以下四个必须的方法:
| 方法 | 调用时机 |
|---|---|
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
必须实现的委托方法
上述四个委托方法必须在您的项目中创建(即使不包含任何逻辑)。否则,项目将无法成功编译。
步骤 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
调用 prepareDocumentCamera 并传入 SDK 配置。当摄像头就绪时,会触发 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 { }
有关完整的结果处理,请参阅接收结果。