金融级实人认证服务Android SDK提供自定义UI颜色、icon图标和UI文案的接口,开发者可以通过调用setCustomUIConfig
或setCustomTxtConfig
接口进行自定义。本文为您介绍UI自定义接口说明以及相关的代码示例。
部分自定义配置可能需要依赖SDK升级,建议您在使用之前将SDK升级至最新版本。
自定义UI颜色和icon图标
目前仅支持自定义引导页和活体认证页的颜色和icon图标。
接口说明
Android SDK中提供了自定义UI颜色和icon图标的接口:setCustomUIConfig
。
/**
* @description 此接口用于设置自定义UI。
* @param {int} paramType 参数类型,可传范围(
* ZIMFacade.ZIM_EXT_PARAMS_VAL_ZIM_EXT_PARAMS_CONFIG_ASSETS_NAME
* /ZIMFacade.ZIM_EXT_PARAMS_VAL_ZIM_EXT_PARAMS_CONFIG_FILE_PATH
* /ZIMFacade.ZIM_EXT_PARAMS_VAL_ZIM_EXT_PARAMS_CONFIG_FILE_JSON)。
* @param {String} param 参数值,paramType相对应的值。
* @return 配置文件检测出的异常信息。
*/
public String setCustomUIConfig(int paramType, String param) {
...
}
参数说明:
名称
类型
说明
paramType
int
配置自定义入参的类型:
ZIMFacade.ZIM_EXT_PARAMS_VAL_ZIM_EXT_PARAMS_CONFIG_ASSETS_NAME:
传入App assets文件类型,param需要传入assets文件名称。
ZIMFacade.ZIM_EXT_PARAMS_VAL_ZIM_EXT_PARAMS_CONFIG_FILE_PATH:
传入设备本地路径,params需要传入配置文件的设备绝对路径地址。
ZIMFacade.ZIM_EXT_PARAMS_VAL_ZIM_EXT_PARAMS_CONFIG_FILE_JSON:
传入JSON字符串,params需传入JSON格式的数据。
param
String
与paramType配套调用。
返回值:String类型,当SDK对param内容解析遇到错误或出现异常信息时会通过提示信息的方式返回。当配置参数无效时,请重点关注返回值信息。
示例代码
//传入文件路径
File file = new File(getFilesDir() + "/dtf/config_test/DTFConsumUIConfig.json");
String path = file.getAbsolutePath();
int paramType = ZIMFacade.ZIM_EXT_PARAMS_VAL_ZIM_EXT_PARAMS_CONFIG_FILE_PATH;
customUIErrMsg = zimFacade.setCustomUIConfig(paramType, path);
//传入assets文件名
String fileName = "DTFConsumUIConfig.json";
int paramType = ZIMFacade.ZIM_EXT_PARAMS_VAL_ZIM_EXT_PARAMS_CONFIG_ASSETS_NAME;
customUIErrMsg = zimFacade.setCustomUIConfig(paramType, fileName);
//传入JSON字符串
String jsonConfig="";
int paramType = ZIMFacade.ZIM_EXT_PARAMS_VAL_ZIM_EXT_PARAMS_CONFIG_FILE_JSON;
customUIErrMsg = zimFacade.setCustomUIConfig(paramType, jsonConfig);
字段定义
字段列表
{
"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/rhtAAAAAXNSR0IArs4c6QAAAERlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAKKADAAQAAAABAAAAKAAAAAB65masAAAEgElEQVRYCc1ZW2gVV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+bc1td6+Pe5fBlEWVdOiJBnj9YpgbcZwyEAFk9Hs8hBBjkNKS6tmWhvV9mBJozLrso2JM4/VhW7pFWjj7Ng60Ov5srCZ6Wq8kqj+RG5Zy1lodpZGMp+unWVtncTE5KF1E1+wel0+fsrqgm/upTve0ex97Rw13F2mjMyuSw2+ep6CVZUrB7bamGqi3SsBVSm21IvFxvZPrMHJ7dY0Jt+ZpIiCBrLVoan5IbBmN3DupvxF0zAm718+BD4YF60TkKh+zzw0SYmPupINM1kHcI1HkQ5TP54GfiIHT3V6mZSaqudbvxSaRntV+LHTgCBIh/1qc23T3m9LHT/rmAtUtSgdfTwj5+Ompnp5mouclwAL+9OHkBNk4X48MqFNR9JhW3if3wzIdDQL8wNmAGThfgIOANVH9K/J3fYRPbnVeUHY9glSB36dqXVs1cHLMLv5+w3xPyaCG6DbMlfXAAAAAElFTkSuQmCC",
"noticeTxtColor": "#1677FF",
"noticeBgColor": "#0F1677FF"
}
}
字段详细说明
展开折叠面板查看字段详细说明。
自定义UI颜色和icon字段详细说明
自定义UI文案
目前仅支持自定义引导页和活体认证页的展示文案。
接口说明
SDK中提供了自定义UI文案的接口:setCustomTxtConfig
。
/**
* @description 设置自定义UI。
* @param {int} paramType 参数类型,可传范围(ZIMFacade.ZIM_EXT_PARAMS_VAL_ZIM_EXT_PARAMS_CONFIG_ASSETS_NAME
* /ZIMFacade.ZIM_EXT_PARAMS_VAL_ZIM_EXT_PARAMS_CONFIG_FILE_PATH
* /ZIMFacade.ZIM_EXT_PARAMS_VAL_ZIM_EXT_PARAMS_CONFIG_FILE_JSON)
* @param {String} params 参数值,paramType相对应的值
* @return 配置文件检测出的异常信息。
*/
public String setCustomTxtConfig(int paramType, String param) {
...
}
参数说明
名称
类型
说明
paramType
int
配置自定义入参的类型,可选值:
ZIMFacade.ZIM_EXT_PARAMS_VAL_ZIM_EXT_PARAMS_CONFIG_ASSETS_NAME:
传入App assets文件类型,param需要传入assets文件名称。
ZIMFacade.ZIM_EXT_PARAMS_VAL_ZIM_EXT_PARAMS_CONFIG_FILE_PATH:
传入设备本地路径,params需要传入配置文件的设备绝对路径地址。
ZIMFacade.ZIM_EXT_PARAMS_VAL_ZIM_EXT_PARAMS_CONFIG_FILE_JSON:
传入JSON字符串,params传入JSON格式的数据。
param
String
与paramType配套调用。
返回值:String类型,当SDK对param内容解析遇到错误或出现异常信息时会通过提示信息的方式返回。当配置参数无效时,请重点关注返回值信息。
示例代码
//传入文件路径
File file = new File(getFilesDir() + "/dtf/config_test/DTFConsumTxtConfig.json");
String path = file.getAbsolutePath();
int paramType = ZIMFacade.ZIM_EXT_PARAMS_VAL_ZIM_EXT_PARAMS_CONFIG_FILE_PATH;
customUIErrMsg = zimFacade.setCustomTxtConfig(paramType, path);
//传入assets文件名
String fileName = "DTFConsumTxtConfig.json";
int paramType = ZIMFacade.ZIM_EXT_PARAMS_VAL_ZIM_EXT_PARAMS_CONFIG_ASSETS_NAME;
customUIErrMsg = zimFacade.setCustomTxtConfig(paramType, fileName);
//传入json字符串
String jsonConfig="";
int paramType = ZIMFacade.ZIM_EXT_PARAMS_VAL_ZIM_EXT_PARAMS_CONFIG_FILE_JSON;
customUIErrMsg = zimFacade.setCustomTxtConfig(paramType, jsonConfig);
字段定义
字段列表
{
"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": "再清晰一点",
"hasHat" : "请摘掉帽子",
"faceOcclusion" : "请移除遮挡"
"faceInitTxt": "请正对屏幕",
"faceTitleBlink": "拿起手机,眨眨眼",
"leftYawLiveness": "拿起手机,向左摇头",
"rightYawLiveness": "拿起手机,向右摇头",
"photinusCommTips": "请把脸移入圈内保持不动",
"qualityTitle": "勿遮挡、倾斜、逆光拍摄",
"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接口函数定义。
名称 | 说明 | 类型 |
params_key_need_permission_toast | SDK获取权限时是否需要弹窗说明权限目的,仅当设置为true时SDK会弹窗。 | true |
params_key_need_permission_toast_duration | 权限toast持续时间,单位毫秒。需要同时打开SDK权限提醒toast开关。 | 2000 |
示例代码
HashMap<String, String> extParams = new HashMap<>();
//如获取权限时需要SDK弹出权限提醒toast,请设置此项
extParams.put(ZIMFacade.ZIM_EXT_PARAMS_KEY_NEED_PERMISSION_TOAST, ZIMFacade.ZIM_EXT_PARAMS_VAL_NEED_PERMISSION_TOAST_TRUE);
//如想修改SDK权限提醒toast的显示持续时间,请设置此项,单位为毫秒
extParams.put(ZIMFacade.ZIM_EXT_PARAMS_KEY_NEED_PERMISSION_TOAST_DURATION, "2000");
zimFacade.verify(certifyId, true, extParams, new ZIMCallback() {
@Override
public boolean response(ZIMResponse response) {
if (null != response && 1000 == response.code) {
// 认证成功
Toast.makeText(getApplicationContext(),
"认证成功\n" +
"code: " + response.code + "\n" +
"reason: " + response.reason,
Toast.LENGTH_LONG).show();
} else {
// 认证失败
Toast.makeText(getApplicationContext(),
"认证失败\n" +
"code: " + response.code + "\n" +
"reason: " + response.reason,
Toast.LENGTH_LONG).show();
}
return true;
}
});
弹窗自定义接口
当Android SDK默认的弹框不足以满足业务诉求时,您可以通过ZIMUICustomListener接口自定义弹窗能力。
接口说明
/**
* 设置UI自定义回调
* @param uiListener
*/
public void setCustomUIListener(ZIMUICustomListener uiListener) {
....
}
public interface ZIMUICustomListener {
......
/**
* SDK请求权限时回调通知
* @return 是否实现权限提示弹窗
*/
boolean onPermissionRequest(Activity activity, List<String> requestPerms, String verifyType);
}
参数说明
名称
类型
说明
activity
Activity
当前请求权限的Activity。
requestPerms
List<String>
当前请求权限的列表。
verifyType
String
当前请求权限的业务。
FACE:活体业务。
OCR:证件业务。
WISH:多因子意愿业务。
返回值:bool类型。当您需要自行处理弹窗时,返回设置为true;若需要默认弹窗,则返回值设置为false。
示例代码
/**
* @return 是否实现权限提示弹窗
*/
zimFacade.setCustomUIListener(new ZIMUICustomListener() {
...
@Override
public boolean onPermissionRequest(Activity activity, List<String> requestPerms, String verifyType) {
Toast.makeText(activity, "PermissionRequest", Toast.LENGTH_SHORT).show();
return true;
}
});=