更新时间:2020-05-14 15:54
在mPaaS项目中集成 阿里云金融级实人认证 和在普通 iOS 原生项目中的步骤并不完全一致,需要处理好共享组件库之间的冲突,并在 mPaaS 项目中注册好实人认证服务的 拦截器。
接入步骤如下:
frameworks
文件夹下所有的 framework 文件添加到工程中:Resources
目录中,并确保在 Build Phases
> Copy Bundle Resources
中包含这四个 bundle :APBToygerFacade.bundle
:位于 APBToygerFacade.framework
中。ToygerService.bundle
:位于 ToygerService.framework
中。BioAuthEngine.bundle
:位于 BioAuthEngine.framework
中。AlipayVerifyBundle.bundle
:位于 framework
文件夹中。info.plist
中配置允许使用相机权限:-ObjC
、-framework "BioAuthAPI"
、-lxml2
三个设置:在 mPaaS 项目中,需要通过拦截器对认证业务的请求进行特殊处理。拦截器 ZolozMobileInterceptor
已经实现,并包含在实人认证 SDK 中,此处需要把该拦截器注册到 mPaaS 拦截器配置中。同时,需要打开 mPaaS 容器 shouldWKDispatchStartEvent
开关。
代码示例如下:
// 位置:DTFrameworkInterface+DEMO.m
...
- (void)application:(UIApplication *)application beforeDidFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
// Step 1. 初始化 mPaaS H5 容器
[MPNebulaAdapterInterface initNebula];
// Step 2. 初始化 RPC 拦截器
[MPRpcInterface initRpc];
// Step 3. 配置 Zoloz 必要的拦截器
ZolozMobileInterceptor *zolozIcp = [[ZolozMobileInterceptor alloc] init];
[MPRpcInterface addRpcInterceptor:zolozIcp];
//Step 4.人脸模块初始化。
[ZolozSdk init];
}
- (void)application:(UIApplication *)application afterDidFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
//Step 5. Nebula 容器配置修改
NBServiceConfigurationGet().shouldWKDispatchStartEvent = YES;
}
...
服务调用方法如下:
// URL字段为生产的认证地址
[[APVerifyService sharedService] startVerifyService:@{@"url": url?:@"",
@"certifyId": @"test-certifyId",
@"ext": @"test-extInfo"
} target:self block:^(NSMutableDictionary * resultDic){
NSLog(@"%@", resultDic);
}];
正确拉起服务,完成验证后,应该见到如下界面:
点击这里 下载代码示例。
在文档使用中是否遇到以下问题
更多建议
匿名提交