金融级实人认证服务iOS SDK提供自定义UI颜色、icon图标和UI文案的接口,开发者可以通过调用setCustomUI
或setCustomTxtConfig
接口进行自定义。本文为您介绍UI自定义接口说明以及相关的代码示例。
部分自定义配置可能需要依赖SDK升级,建议您在使用之前将SDK升级至最新版本。
自定义UI颜色和icon图标
目前仅支持自定义引导页和活体认证页的颜色和icon图标。
接口说明
iOS SDK中提供了自定义UI颜色和icon图标的接口:setCustomUI
。
/**
* 设置自定义UI
* @param customConfig
* 传入JSON文件路径或者JSON字符串
* @param type
* 传入的config类型path或者json
* @param completion配置文件结果回调
* */
+ (void)setCustomUI:(nonnull NSString *)configuration type:(nonnull NSString *)type completion:(void(^)(BOOL success, NSError *error))completion;
参数说明
名称
类型
说明
configuration
NSString
配置自定义入参的类型:
json:传入JSON字符串。
path:传入JSON文件的沙盒路径。
type
NSString
根据传入的configuration,选择传入json或path。
completion
block
结果信息回调。
success为YES表示设置成功。
success为NO表示设置的内容存在问题,具体请查看对应返回的error说明。
返回值:无。
示例代码
//传入文件路径
NSString *path = @"/var/mobile/Containers/Data/Application/C9DF10E6-7AB4-4C66-A180-DF1080C93F72/Documents/uiCustom.json";
[AliyunFaceAuthFacade setCustomUI:path type:@"path" completion:^(BOOL success, NSError * _Nonnull error) {
NSLog(@"%@",error.localizedDescription);
}];
//传入JSON字符串
NSString *jsonString = @"{""\"guideConfig\": \"#FF0000\""}";
[AliyunFaceAuthFacade setCustomUI:jsonString type:@"json" completion:^(BOOL success, NSError * _Nonnull error) {
NSLog(@"%@",error.localizedDescription);
}];
字段定义
字段列表
{
"guideConfig": {
"titleColor": "#111111",
"titleBackPath": "",
"titleBackBase64": "",
"titleClosePath": "",
"titleCloseBase64": "",
"bannerImg": "",
"agrtUnSelColor": "#c5c5c5",
"agrtSelBgColor": "#ff6a00",
"agrtAgreeColor": "#333333",
"agrtColor": "#ff6a00",
"startBtnColor": "#ffffff",
"agrtBotTipsColor": "#333333",
"startBtnDisColor": "#ffffff",
"startBtnBgColor": "#ff6a00",
"startBtnDisBgColor": "#d9d9d9",
"elderBtnDisColor": "#ffffff",
"elderBtnBgColor": "#f0f0f0",
"elderBtnDisBgColor": "#d9d9d9",
"exitBtnColor": "#333333",
"exitBtnBgColor": "#ffffff",
"elderBtnColor": "#ff6a00",
"rareFormEntBtnColor": "#ff6a00",
"permissionToastBgColor": "#ffffff",
"permissionToastTitleColor": "#000000",
"permissionToastMsgColor": "#000000",
"dialogExitTitleColor": "#000000",
"dialogExitMsgColor": "#000000",
"dialogExitCancelColor": "#0E83E6",
"dialogExitConfirmColor": "#0E83E6",
"dialogPermissionFailedTitleColor": "#000000",
"dialogPermissionFailedMsgColor": "#000000",
"dialogPermissionFailedConfirmColor": "#0E83E6",
"dialogSupportFailedTitleColor": "#000000",
"dialogSupportFailedMsgColor": "#000000",
"dialogSupportFailedConfirmColor": "#0E83E6",
"dialogNetworkFailedTitleColor": "#000000",
"dialogNetworkFailedMsgColor": "#000000",
"dialogNetworkFailedConfirmColor": "#0E83E6"
},
"faceConfig": {
"faceBgColor": "#FFFFFF",
"faceTitleColor": "#000000",
"circleTxtBgAlpha": "0.25",
"dialogBgAlpha": "0.25",
"faceProgressStartColor": "#dfe6eb",
"faceProgressEndColor": "#FF6A00",
"circleTxtColor": "#ffffff",
"exitIconPath": "",
"exitIconBase64": "",
"submitTextColor": "#E4E4E4",
"submitLoadingIconBase64": "",
"submitLoadingIconPath": "",
"dialogExitTitleColor": "#000000",
"dialogExitMsgColor": "#000000",
"dialogExitCancelColor": "#0E83E6",
"dialogExitConfirmColor": "#0E83E6",
"dialogTimeOutTitleColor": "#000000",
"dialogTimeOutMsgColor": "#000000",
"dialogTimeOutConfirmColor": "#0E83E6",
"dialogNetworkFailedTitleColor": "#000000",
"dialogNetworkFailedMsgColor": "#000000",
"dialogNetworkFailedConfirmColor": "#0E83E6",
"dialogArchSysFailedTitleColor": "#000000",
"dialogArchSysFailedMsgColor": "#000000",
"dialogArchSysFailedConfirmColor": "#0E83E6",
"dialogTooManyRetriesTitleColor": "#000000",
"dialogTooManyRetriesMsgColor": "#000000",
"dialogTooManyRetriesConfirmColor": "#0E83E6",
"dialogInterruptTitleColor": "#000000",
"dialogInterruptMsgColor": "#000000",
"dialogInterruptConfirmColor": "#0E83E6",
"dialogInterruptCancelColor": "#0E83E6",
"dialogSDKErrTitleColor": "#000000",
"dialogSDKErrMsgColor": "#000000",
"dialogSDKErrConfirmColor": "#0E83E6",
"dialogCamOpenFailedTitleColor": "#000000",
"dialogCamOpenFailedMsgColor": "#000000",
"dialogCamOpenFailedConfirmColor": "#0E83E6",
"dialogCamOpenFailedCancelColor": "#0E83E6",
"noticeIconPath": "",
"noticeIconBase64": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAAAXNSR0IArs4c6QAAAERlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAKKADAAQAAAABAAAAKAAAAAB65masAAAEgElEQVRYCc1ZW2gVVxRd10d9pcVXo0arxkiKGlFr/bAgCPql+IoRW1pBabUqSqXQ74mW9qP40VJKWxFLERVFjREjih8qfuiHQUQtWiMK1sQY2oqPpL4yXevee8zM3Jm558abeDdszpmzH2fNnjP77DOTQCfJdd0ymi4iTyeXeJhdNHq4nv3aRCJxQ4IuJYIqJm8hXyLnSrKRbXHeQdJpEdkhPyS/KsmHQy7KC1A6qiTfJeeb5LOy0yBpnCA75HZyV5F8O+RETkBp0I+8j9xdpLn6WYGkoiLXneBMEDRn9khSyTEWubRtz1z3m2Ou++UB121oycXSp+sEo+hDTFUt2v1k33jQKHjd9ABYtRO4cDslKeoDfF8FLJgc1Mx67VKjijnzoNF8CYTg9No3kIcZYbb20RNgz3nguxPAg/8ytRdPAb6aC4x/O1MWM9JM2XiCfCQdL0CFt1qDQXrRDtRdAS7+BbTzHv9pBW60AFeagNanQe3M63Km5nLe9oi3gL69gSEDgGXvAUPZRlA1AW6WLAmQ0VN211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}
}
对应列表
展开折叠面板查看字段详细说明。
自定义UI颜色和icon字段详细说明
文案自定义
目前仅支持自定义引导页和活体认证页的展示文案。
接口说明
SDK中提供了自定义UI的接口:setCustomTxtConfig
。
/**
* 设置自定义文案
* @param customConfig
* 传入json文件路径或者json字符串
* @param type
* 传入的config类型path或者json
* @param completion配置文件结果回调
* */
+ (void)setCustomLanguage:(nonnull NSString *)configuration type:(nonnull NSString *)type completion:(void(^)(BOOL success, NSError *error))completion;
参数说明
名称
类型
说明
configuration
NSString
配置自定义入参的类型:
json:传入JSON字符串。
path:传入JSON文件的沙盒路径。
type
NSString
根据传入的configuration,选择传入json或path。
completion
block
结果信息回调。
success为YES表示设置成功。
success为NO表示设置的内容存在问题,具体请查看对应返回的error说明。
返回值:无。
示例代码
//传入文件路径
NSString *path = @"/var/mobile/Containers/Data/Application/C9DF10E6-7AB4-4C66-A180-DF1080C93F72/Documents/customLanguage.json";
[AliyunFaceAuthFacade setCustomLanguage:path type:@"path" completion:^(BOOL success, NSError * _Nonnull error) {
NSLog(@"%@",error.localizedDescription);
}];
//传入json字符串
NSString *jsonString = @"{""\"titleText\": \"刷脸认证\""}";
[AliyunFaceAuthFacade setCustomLanguage:jsonString type:@"json" completion:^(BOOL success, NSError * _Nonnull error) {
NSLog(@"%@",error.localizedDescription);
}];
字段定义
字段列表
{
"guideConfig": {
"titleText": "刷脸认证",
"agrtTopTipsText": "请先勾选协议",
"agrtAgreeText": "同意",
"agrtText": "《认证服务协议》",
"agrtBotTipsText": "同意认证后,将获取您的摄像头权限用于人脸识别验证身份",
"startBtnText": "开始认证",
"elderBtnText": "长辈模式认证",
"exitBtnText": "暂不认证",
"authPermissionSDKName": "实人认证",
"authPermissionAPPName": "阿里云实人认证",
"authPermissionCamera": "相机",
"authPermissionAudio": "录音",
"authPermissionScreenEvidence": "录屏",
"authPermissionToastTitle": "",
"authPermissionToastMsg": "",
"dialogExitTitle": "确定退出吗?",
"dialogExitMsg": "露个脸就能通过",
"dialogExitConfirm": "确定",
"dialogExitCancel": "取消",
"dialogPermissionFailedTitle": "认证失败",
"dialogPermissionFailedMsg": "请确认相关权限已开启后再次发起",
"dialogPermissionFailedConfirm": "确认",
"dialogNetworkFailedTitle": "网络不给力",
"dialogNetworkFailedMsg": "请检查网络",
"dialogNetworkFailedConfirm": "确定",
"dialogSupportFailedTitle": "当前系统不支持刷脸",
"dialogSupportFailedMsg": "刷脸仅在高版本及以上系统可用",
"dialogSupportFailedConfirm": "确定"
},
"faceConfig": {
"faceNotFound": "没有检测到脸",
"faceTooFar": "靠近一点",
"faceTooClose": "离远一点",
"faceNotIn": "把脸移入圈内",
"badPitch": "请正对手机",
"badYaw": "请正对手机",
"faceTooMore": "请保持单人操作",
"faceIsMoving": "再清晰一点",
"faceBrightless": "脸部亮一点",
"faceBadQuality": "请露出正脸",
"eyesOnScreen": "请注视屏幕",
"blink": "眨眨眼",
"leftYaw": "向左摇头",
"rightYaw": "向右摇头",
"stackTime": "请保持不动",
"isBlur": "再清晰一点",
"faceInitTxt": "请正对屏幕",
"faceTitleBlink": "拿起手机,眨眨眼",
"leftYawLiveness": "拿起手机,向左摇头",
"rightYawLiveness": "拿起手机,向右摇头",
"photinusCommTips": "请把脸移入圈内保持不动",
"processing": "正在处理",
"dialogTimeOutTitle": "操作超时",
"dialogTimeOutMsg": "正对手机,更容易成功",
"dialogTimeOutConfirm": "再试一次",
"dialogInterruptTitle": "验证中断",
"dialogInterruptConfirm": "再试一次",
"dialogInterruptCancel": "退出",
"dialogTooManyRetriesTitle": "本次操作失败",
"dialogTooManyRetriesMsg": "刷脸失败次数过多,请稍后再试",
"dialogTooManyRetriesConfirm": "我知道了",
"dialogExitTitle": "确定退出吗?",
"dialogExitMsg": "露个脸就能通过",
"dialogExitConfirm": "确定",
"dialogExitCancel": "取消",
"dialogCamOpenFailedTitle": "摄像头打开异常",
"dialogCamOpenFailedMsg": "请重启app或手机后再次尝试",
"dialogCamOpenFailedConfirm": "确定",
"dialogCamOpenFailedCancel": "取消",
"dialogArchSysFailedTitle": "当前系统不支持刷脸",
"dialogArchSysFailedMsg": "刷脸仅在高版本及以上系统可用",
"dialogArchSysFailedConfirm": "确定",
"dialogSDKErrTitle": "本次操作失败",
"dialogSDKErrMsg": "抱歉,系统出错了,请再试一次",
"dialogSDKErrConfirm": "确定",
"dialogNetworkFailedTitle": "网络不给力",
"dialogNetworkFailedMsg": "请检查网络",
"dialogNetworkFailedConfirm": "确定",
"verifyNotice": "您正在进行实人认证,请确保本人操作!"
}
}
字段详细说明
展开折叠面板查看字段详细说明。
自定义UI文案字段详细说明
合规权限提醒
SDK为了保证基础功能的运行需要向客户申请对应功能的权限,为了保证您的应用对客户展示合规,SDK内部提供了权限获取以及使用说明提醒弹窗,该功能默认关闭,当您需要使用时请通过verify接口进行开启。
开关接口
接口说明
请参考对应方案的Verify接口函数定义。
名称 | 说明 | 类型 |
ZIM_EXT_PARAMS_KEY_NEED_PERMISSION_TOAST | SDK获取权限前是否弹窗 | [extParams setValue:@"true" forKey:ZIM_EXT_PARAMS_KEY_NEED_PERMISSION_TOAST]; |
ZIM_EXT_PARAMS_KEY_PERMISSION_TOAST_DURATION | 弹窗时间 | [extParams setValue:@(3000) forKey:ZIM_EXT_PARAMS_KEY_PERMISSION_TOAST_DURATION]; |
示例代码
NSMutableDictionary *extParams = [NSMutableDictionary dictionary];
//需要使用权限toast
[extParams setValue:@"true" forKey:ZIM_EXT_PARAMS_KEY_NEED_PERMISSION_TOAST];
[extParams setValue:@(3000) forKey:ZIM_EXT_PARAMS_KEY_PERMISSION_TOAST_DURATION];
.....
[AliyunFaceAuthFacade verifyWith:certifyId extParams:extParams onCompletion:^(ZIMResponse *response) {
}];
弹窗自定义接口
当SDK默认的弹框不足以满足业务诉求时,您可以通过DTFUICustomProtocol接口自定义弹窗能力。
接口说明
请参考对应方案的Verify接口函数定义。
名称 | 说明 | 类型 |
UICustomProtocol | 权限弹框自定义对象 | [extParams setValue:self forKey:@"UICustomProtocol"]; |
/**
* 实现Protocol方法
* @param permission,需要获取的权限
* @param serviceType,需要获取的权限类型
* return:BOOL类型,当您需要自行处理弹窗时,返回YES即可,否则SDK会根据开关配置决定是否进行弹窗
* */
- (BOOL)showPermissionViewWithPermission:(NSArray *)permission serviceType:(DTFServiceType)serviceType{
//实现弹窗样式并展示
return YES;
}
参数说明
名称
类型
说明
permission
NSArray
当前请求权限的列表。
serviceType
String
当前请求权限的业务。
FACE:活体业务。
OCR:证件业务。
WISH:多因子意愿业务。
返回值:bool类型。当您需要自行处理弹窗时,返回设置YES;若需要默认弹窗,则返回值设置NO。
示例代码
@interface PermissionView : NSObject<DTFUICustomProtocol>
- (BOOL)showPermissionViewWithPermission:(NSArray *)permission serviceType:(DTFServiceType)serviceType;
@end
@implementation PermissionView
/**
* 实现Protocol方法
* @param permission
* 需要获取的权限
* @param serviceType
* 需要获取的权限类型
* return:BOOL类型,当您需要自行处理弹窗时,返回YES即可,否则SDK会根据开关配置决定是否进行弹窗
* */
- (BOOL)showPermissionViewWithPermission:(NSArray *)permission serviceType:(DTFServiceType)serviceType{
//实现弹窗样式并展示
return YES;
}
@end
NSMutableDictionary *extParams = [NSMutableDictionary dictionary];
PermissionView *permissionView = [PermissionView alloc]init];
// 把实现了Protocol的对象传入
[extParams setValue:permissionView forKey:@"UICustomProtocol"];
.....
[AliyunFaceAuthFacade verifyWith:certifyId extParams:extParams onCompletion:^(ZIMResponse *response) {
}];