有奖:语音产品征文挑战赛火热进行中> HOT

SDK 接口调用方法

SDK 的功能通过 WBFaceVerifyCustomerService 这个类的方法进行调用,其中 SDK 中使用的 nonce,sign 等重要信息,需要合作方从自己后台拉取,并且两者不能缓存,使用后即失效,详细接口说明如下,其他的操作请参考 Demo 中的登录接口的参数说明:

版本号及宏定义说明

#import <UIKit/UIKit.h>
#ifndef WBFaceVerifyConst_h
#define WBFaceVerifyConst_h
#define WBCloudReflectionFaceVerifyVersion
?
UIKIT_EXTERN NSString *const WBCloudFaceVerifySDKVersion;
?
/**
?SDK使用的主题风格
?
?- WBFaceVerifyThemeDarkness: 暗黑色系主题
?- WBFaceVerifyThemeLightness: 明亮色系主题
?- WBFaceVerifyThemeOrange: 橙色主题
?- WBFaceVerifyThemeCustom: 自定义主题,通过修改 bundle 中的 custom.json 实现自定义
?
?*/
typedef NS_ENUM(NSInteger, WBFaceVerifyTheme) {
? ? WBFaceVerifyThemeDarkness = 0,
? ? WBFaceVerifyThemeLightness,
? ? WBFaceVerifyThemeOrange,
? ? WBFaceVerifyThemeCustom,
};
?
typedef NS_ENUM(NSInteger, WBFaceVerifyLanguage) {
? ? WBFaceVerifyLanguage_ZH_CN = 0, //简体中文
? ? WBFaceVerifyLanguage_ZH_HK, ? ? //繁体中文
? ? WBFaceVerifyLanguage_EN,? ? ? ? //英语
? ? WBFaceVerifyLanguage_ID,? ? ? ? //印尼语
? ? WBFaceVerifyLanguage_JA,? ? ? ? //日语
? ? WBFaceVerifyLanguage_KO,? ? ? ? //韩语
? ? WBFaceVerifyLanguage_TH ? ? ? ? //泰语
};
?
typedef NS_ENUM(NSInteger, WBFaceCustomTipsLoc) {
? ? WBFaceCustomTipsLoc_Bottom = 0, //提示语在下
? ? WBFaceCustomTipsLoc_Top,
};
#endif /* WBFaceVerifyConst_h */

入口方法说明

NONCE 类型的 ticket,其有效期为120秒,且一次性有效,即每次启动 SDK 刷脸都要重新请求 NONCE ticket,重新算 sign。同时建议合作方做前端保护,防止用户连续点击,短时间内频繁启动 SDK。 faceID +活体检测+人脸比对服务
/*
增强级SDK核身入口,注意传入的 faceId 不能为空,且必须为增强 faceId,否则会报 failure
?
@param userid 用户唯一标识,由合作方自行定义
@param nonce? 满足接入要求的32位随机数
@param sign 获取方式请参考 [生成 SDK 接口调用步骤使用签名](/document/product/1007/63358)
@param appid 业务流程唯一标识,即 wbappid,可参考 获取 WBappid 指引在人脸核身控制台内申请
@param orderNo 每次人脸身份认证请求的唯一订单号: 建议为32位字符串(不超过32位)
@param apiVersion 后台 api 接口版本号(不是 SDK 的版本号),默认请填写@"1.0.0"
@param licence 在人脸核身控制台内申请(该 licence 同 App 当前使用的 bundle id 绑定)
@param faceId 合作方必须要先获取*增强级*faceId,再送入sdk,不允许为空,比对or活体检测服务由 sdkConfig.useAdvanceCompare 设置
@param sdkConfig SDK 基础配置项目
@param success 服务登录成功回调,登录成功以后开始进行活体和检测服务
@param failure 服务登录失败回调,具体参考错误码文档
*/
-(void)initAdvanceSDKWithUserId:(NSString *)userid
? ? ? ? ? ? ? ? ? ? ? ? ? nonce:(NSString *)nonce
?? ? ? ? ? ? ? ? ? ? ? ? ? sign:(NSString *)sign
? ? ? ? ? ? ? ? ? ? ? ? ? appid:(NSString *)appid
? ? ? ? ? ? ? ? ? ? ? ? orderNo:(NSString *)orderNo
?? ? ? ? ? ? ? ? ? ? apiVersion:(NSString *)apiVersion
? ? ? ? ? ? ? ? ? ? ? ? licence:(NSString *)licence
?? ? ? ? ? ? ? ? ? ? ? ? faceId:(nonnull NSString *)faceId
? ? ? ? ? ? ? ? ? ? ? sdkConfig:(WBFaceVerifySDKConfig *)sdkConfig
? ? ? ? ? ? ? ? ? ? ? ? success:(void (^)())success
? ? ? ? ? ? ? ? ? ? ? ? failure:(void (^)(WBFaceError * _Nonnull))failure;
/**
?以上一次的登录结果拉起刷脸页面,必须先登录再拉起刷脸页面
?
?@return 拉起是否成功
?*/
- (BOOL)startWbFaceVeirifySdk;

个性化参数设置

SDK 登录接口 initSDK 方法中需要传入 WBFaceVerifySDKConfig 字段,通过该对象可以配置 SDK 中其他基础配置:包括设置主题风格,资源路径等,仅活体 or 比对服务,通过 useAdvanceCompare 属性区分,务必根据自己的业务进行设置,具体参考头文件。
/**
?人脸识别 SDK 基础配置类
?*/
@interface WBFaceVerifySDKConfig : NSObject
?
#pragma mark - common
/**
?sdk中拉起人脸活体识别界面中使用UIWindow时的windowLevel配置,默认配置是1 + UIWindowLevelNormal
?
?如果接入放app中有其他自定义UIWindow, 为了防止界面覆盖,可以酌情设置该参数
?*/
@property (nonatomic, assign) NSUInteger windowLevel;
?
/**
是否境外用户
默认:NO
请注意:如果合作方可以分辨国内或者境外ip,建议境外ip开启这个配置,国内ip访问不进行配置
*/
@property (nonatomic, assign) BOOL isAbroad;
?
/**
人脸识别服务是否进行通过录像,从而进行视频存证
?
?default: NO
?*/
@property (nonatomic, assign) BOOL recordVideo;
?
/**
?是否由 SDK 内部处理 sdk 网络请求的 cookie
?
?默认值: YES
?*/
@property (nonatomic, assign) BOOL manualCookie;
?
/**
?人脸识别页面中的主题风格, 需要配合不同资源包使用:
?WBFaceVerifyThemeDarkness - 暗灰主题
WBFaceVerifyThemeLightness - 明亮主题(默认)
*/
@property (nonatomic, assign) WBFaceVerifyTheme theme;
/**
?多语言配置
?默认中文,当使用其他语言时,强制静音
?*/
@property (nonatomic, assign) WBFaceVerifyLanguage language;
/**
?是否静音
?默认值:YES
?*/
@property (nonatomic, assign) BOOL mute;
/*
?送入自定义提示文案的位置
?默认:WBFaceCustomTipsLoc_Bottom
?*/
@property (nonatomic, assign) WBFaceCustomTipsLoc tipsLoc;
?
/*
?检测过程中展示的文案
?默认为空
?*/
@property (nonatomic, copy) NSString *customTipsInDetect;
?
/*
?上传过程中展示的文案
?默认为空
?*/
@property (nonatomic, copy) NSString *customTipsInUpload;
?
/*
?底部提示文案,长度不超过70字
?*/
@property (nonatomic, copy) NSString *bottomCustomTips;
/*
?退出二次确认UI配置
?*/
@property (nonatomic, copy) NSString *exitAlertTitle; //标题
@property (nonatomic, copy) NSString *exitAlertMessage; //内容
@property (nonatomic, copy) NSString *exitAlertRight; //右边按钮
@property (nonatomic, copy) NSString *exitAlertLeft; //左边按钮
/*
如果有使用苹果分屏模式(UIWindowScene),打开此开关
Xcode11新建工程有使用 Scene,可以参考资料自行调整
默认为 NO
*/
@property (nonatomic, assign) BOOL useWindowSecene;
?
/**
?资源路径,不包含bundle本身(仅当需要自己下发资源时配置,本地资源无需配置)
?!!!重要:此目录下必须包含face-tracker-v001.bundle和WBCloudReflectionFaceVerify.bundle两个文件,否则无法拉起SDK
?*/
@property (nonatomic, copy) NSString *bundlePath;
?
/**
?是否采用增强比对服务,仅增强接口生效,仅活体服务设置为 NO
默认为 NO,注意:如果需要使用完整活体+比对服务请设置为 YES
?*/
@property (nonatomic, assign) BOOL useAdvanceCompare;
#pragma mark - simple //非标特有字段,标准模式无需设置
/**
?是否返回录制的视频
?
?default: NO
?*/
@property (nonatomic, assign) BOOL returnVideo;
?
/**
?返回视频加密的公钥,如果不配置则不加密
?
?需要recordVideo returnVideo同时为YES,才返回加密的视频内容
?*/
@property (nonatomic, copy) NSString *publicKey;
?
/**
?AES 加密需要用到的 IV
?*/
@property (nonatomic, copy) NSString *aesIV;
/**
?默认 sdk 配置
?*/
+(instancetype)sdkConfig;
?
@end
?

自定义皮肤设置

可以通过修改 JSON 文件,自定义刷脸的部分 UI。首先把 Theme 设置为 WBFaceVerifyThemeCustom,再修改 JSON 文件,路径:WBCloudReflectionFaceVerify_framework/Resource/WBCloudReflectionFaceVerify.bundle/custom.json
{
"name": "custom",
? ? "statusBarStyle" : ? "light", /** 状态栏颜色 */
? ? "navbarTintColor": ? "0xffffff", /** 导航栏色调 */
? ? "baseNavBarColor" :? "0x0", /** 导航栏默认颜色 */
? ? "authNavBarColor" :? "0x22252A", /** 授权详情页导航栏颜色 */
?
? ? "imageBgColor" : ? ? "0x23262b", /** 刷脸页背景色 */
? ? "faceNormalColor": "0x33FFFFFF", /** 默认刷脸框颜色 */
? ? "faceSatisfyColor": "0x5065FF", /** 人脸框识别成功颜色 */
? ? "faceErrorColor": "0xFF6034", /** 人脸框识别失败颜色 */
?
? ? "guideLabelColor" :? "0xffffff", /** 提示语默认颜色 */
? ? "guideLabelErrorColor" : "0xff5240", /** 识别错误时提示语颜色 */
? ? "customTipsColor": ? "0xFFFFFF", /** 自定义提示语颜色 */
? ? "bottomTipsBgColor": "0x0DFFFFFF", /** 底部提示背景色 */
? ? "bottomTipsTextColor": "0x80FFFFFF", /** 底部提示文案颜色 */
?
? ? "backButtonImage":"backbutton@dark", /** 刷脸页面返回按钮图片 */
? ? "authBackButtonImage":"backbutton@dark", /** 授权页面返回按钮图片 */
? ? "authBodyImage": "wbcf_auth_face@dark", /** 授权页人脸框图片 */
? ? "authCheckboxUnSelectImage":"wbcf_checkbox_unselect", /** 授权页勾选框未勾选图片 */
? ? "authCheckboxSelectImage":"wbcf_checkbox_select", /** 授权页勾选框勾选图片 */
? ? "authCheckboxTipsColor": "0xFFFFFF", /** 授权页勾选提示语颜色 */
? ? "authCheckboxLinkColor": "0x6F80FF", /** 授权页详情链接提示颜色 */
? ? "authAgreeButtonNormalColor": "0xB7C0FF", /** 授权页同意按钮默认颜色 */
? ? "authAgreeButtonHighlightColor": "0x5065FF", /** 授权页同意按钮高亮颜色 */
? ? "authAgreeTextNormalColor":"0xFFFFFF", /** 授权页同意按钮文案默认颜色 */
? ? "authAgreeTextHighlightColor":"0xFFFFFF", /** 授权页同意按钮文案高亮颜色 */
?
? ? "alertTitleColor":"0x000000", /** 弹框主题颜色 */
? ? "alertMessageColor":"0x000000", /** 弹框详细信息颜色 */
? ? "alertLeftBtnColor":"0x5065FF", /** 弹框左边按钮文案颜色 */
? ? "alertRightBtnColor":"0x5065FF", /**弹框右边按钮文案颜色 */
? ? "alertBackgroundColor":"0xFFFFFF", /** 弹框背景色 */
}
注意
1. 需要替换返回按钮图片时,需要修改对应 navbarTintColor 到按钮颜色。
2. 有透明色时,透明度放在前面,例如 80FFFFFF,FFFFFF 代表白色,80代表透明度。
3. 需要替换图片的目录在 JSON 文件同级目录 common 文件夹下,替换时注意保证相同尺寸大小,否则显示会异常。
?


http://www.vxiaotou.com