文档

接口说明

更新时间:

本文介绍图形认证iOS客户端接入时所需的接口信息。

验证会话任务代理协议

回调验证会话结果

获取到验证结果后,需要提交到业务服务端,完成参数的校验。

- (void)alicomCaptchaSession:(AlicomCaptcha4Session *)captchaSession
              didReceive:(NSString *)status
                 result:(nullable NSDictionary *)result;

参数

说明

captchaSession

验证会话

status

状态码。当status为@"1" 时,则为完成,需要对结果进行⼆次校验。

  • @"0":未完成

  • @"1":完成

result

结果校验参数

回调验证会话中的错误

 (void)alicomCaptchaSession:(AlicomCaptcha4Session *)captchaSession
       didReceiveError:(AlicomC4Error *)error;

参数

说明

captchaSession

验证会话

error

错误描述对象

验证会话

验证会话任务代理

@property (nonatomic, weak) id<AlicomCaptcha4SessionTaskDelegate> delegate;

验证当前会话的ID

@property (nonnull, readonly, nonatomic, strong) NSString *captchaID;

验证当前会话的流水号

@property (nullable, readonly, nonatomic, strong) NSString *challenge;

验证当前会话的配置

@property (nonnull, readonly, nonatomic, strong) AlicomCaptcha4SessionConfiguration

创建验证会话实例

+ (instancetype)sessionWithCaptchaID:(NSString *)captchaID;

参数

说明

captchaID

验证ID

配置新创建的验证会话

+ (instancetype)sessionWithCaptchaID:(NSString *)captchaID
      configuration:(nullable AlicomCaptcha4SessionConfiguration

参数

说明

captchaID

验证ID

configuration

会话配置

开始验证

- (void)verify

取消验证

- (void)cancel

获取SDK版本号

+ (NSString *)sdkVersion

验证会话配置

验证界面样式

typedef NS_ENUM(NSInteger, AlicomC4UserInterfaceStyle) {
 /** 跟随系统样式 */
 AlicomC4UserInterfaceStyleSystem = 0,
 /** 普通样式 */
 AlicomC4UserInterfaceStyleLight,
 /** 暗⿊样式 */
 AlicomC4UserInterfaceStyleDark,
 /** 默认样式 */
 AlicomC4UserInterfaceStyleDefault = AlicomC4UserInterfaceStyleLight
}

远程访问静态资源的路径

远程访问静态资源的完整路径,默认为空。

@property (nullable, nonatomic, strong) NSString *resourcePath;

远程访问静态资源的协议

远程访问静态资源时的协议,默认@“https”。

@property (nonatomic, strong) NSString *protocol;

界面样式

界面样式,默认普通白色。

@property (nonatomic, assign) AlicomC4UserInterfaceStyle userInterfaceSty;

背景颜色

背景颜色,默认透明。

@property (nonatomic, strong) UIColor *backgroundColor;

调试模式开关

调试模式开关,默认关闭。

@property (nonatomic, assign) BOOL debugEnable;

点击背景的交互

点击背景的交互,默认开启。

@property (nonatomic, assign) BOOL backgroundUserInteractionEnable;

请求超时时长

请求超时时长,默认8秒。

@property (nonatomic, assign) NSTimeInterval timeout;

设置语言

语⾔,默认跟随系统。指定语言请参考语⾔短码。

@property (nonatomic, strong) NSString *language;

其他参数配置

@property (nullable, nonatomic, strong) NSDictionary *additionalParameter

获取默认配置

+ (AlicomCaptcha4SessionConfiguration *)defaultConfiguration;

返回示例

+ (AlicomCaptcha4SessionConfiguration *)defaultConfiguration {
    AlicomCaptcha4SessionConfiguration *config = [[AlicomCaptcha4SessionConfiguration alloc] init];
    config.debugEnable = NO;
    config.timeout = 8.0;
    config.language = [AlicomC4Utils systemLanguage];
    config.protocol = @"https";
    config.userInterfaceStyle = AlicomC4UserInterfaceStyleDefault;
    config.backgroundColor = [UIColor clearColor];
    config.backgroundUserInteractionEnable = YES;
 
    return config;
 }

错误描述对象

/// 不合法的参数。请检查输入的参数。
FOUNDATION_EXPORT NSString * const AlicomC4ErrorCodeInvalidParameter;
/// 操作失败。详细查看描述。
FOUNDATION_EXPORT NSString * const AlicomC4ErrorCodeOperationFail;
/// 资源缺失。请检查 AlicomCaptcha4.bundle文件是否完整。
FOUNDATION_EXPORT NSString * const AlicomC4ErrorCodeMissedResource;
/// ⽤户取消了验证。
FOUNDATION_EXPORT NSString * const AlicomC4ErrorCodeUserDidCancel;
/// 加载⽂件失败。请检查是否导入了完整的 AlicomCaptcha4.bundle文件或者配置的远程静态资源是否可访问。
FOUNDATION_EXPORT NSString * const AlicomC4ErrorCodeLoadFileFailure;
/// 加载超时。
FOUNDATION_EXPORT NSString * const AlicomC4ErrorCodeTimeout;
/// 执行Javascript 脚本失败。
FOUNDATION_EXPORT NSString * const AlicomC4ErrorCodeEvaluatingJavascriptFail;
/// Javascript 返回错误。
FOUNDATION_EXPORT NSString * const AlicomC4ErrorCodeJavascriptError;
/// WebView 内存警告。
FOUNDATION_EXPORT NSString * const AlicomC4ErrorCodeWebViewMemoryWarning;
/// 未知错误。
FOUNDATION_EXPORT NSString * const AlicomC4ErrorCodeUnknown;

code

错误码

@property (readonly, nonatomic, strong) NSString *code

msg

错误信息

@property (readonly, nonatomic, strong) NSString *msg

desc

错误详细描述

@property (readonly, nonatomic, strong) NSDictionary *desc

  • 本页导读 (1)
文档反馈