添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

[TOC]

Protocol

GT3CaptchaButtonDelegate

captchaButtonShouldBeginCaptcha:

控制是否执行验证事件

Declaration

- (BOOL)captchaButtonShouldBeginCaptcha:(GT3CaptchaButton *)button;

Parameters

Param Description

captchaButton:didChangeState:

验证状态改变的通知回调

Declaration

- (void)captchaButton:(GT3CaptchaButton *)button didChangeState:(GT3CaptchaState)state;

Parameters

Param Description

GT3CaptchaManagerDelegate

gtCaptcha:errorHandler:

内部错误处理

Declaration

- (void)gtCaptcha:(GT3CaptchaManager *)manager errorHandler:(GT3Error *)error;

Parameters

Param Description

gtCaptcha:didReceiveSecondaryCaptchaData:response:error:decisionHandler:

通知已经收到二次验证结果, 并请在此处理最终验证结果

Declaration

- (void)gtCaptcha:(GT3CaptchaManager *)manager didReceiveSecondaryCaptchaData:(NSData *)data response:(NSURLResponse *)response error:(GT3Error *)error decisionHandler:(void (^)(GT3SecondaryCaptchaPolicy captchaPolicy))decisionHandler;

Parameters

Param Description

shouldUseDefaultRegisterAPI:

将要向 API1 发送请求的时候调用此方法

Declaration

- (BOOL)shouldUseDefaultRegisterAPI:(GT3CaptchaManager *)manager;

Parameters

Param Description

Return Value

返回是否使用默认的 API1 行为

gtCaptcha:willSendRequestAPI1:withReplacedHandler:

将要向 API1 发送请求的时候调用此方法, 通过此方法可以修改将要发送的请求

Declaration

- (void)gtCaptcha:(GT3CaptchaManager *)manager willSendRequestAPI1:(NSURLRequest *)originalRequest withReplacedHandler:(void (^)(NSURLRequest * request))replacedHandler;

Parameters

Param Description

gtCaptcha:didReceiveDataFromAPI1:withError:

将要向 API1 发送请求的时候调用此方法, 通过此方法可以修改将要发送的请求

Declaration

- (NSDictionary *)gtCaptcha:(GT3CaptchaManager *)manager didReceiveDataFromAPI1:(NSDictionary *)dictionary withError:(GT3Error *)error;

Parameters

Param Description
  • 参数 dictionary 内数据样例
  • {
    "challenge" : "12ae1159ffdfcbbc306897e8d9bf6d06",
    "gt" : "ad872a4e1a51888967bdb7cb45589605",
    "success" : 1
    }

    Return Value

    返回自定解析后的 challenge , gt , success 数据, 结构参考上方样例

    gtCaptcha:didReceiveCaptchaCode:result:message:

    通知接收到返回的验证交互结果

    Declaration

    - (void)gtCaptcha:(GT3CaptchaManager *)manager didReceiveCaptchaCode:(NSString *)code result:(NSDictionary *)result message:(NSString *)message;

    Parameters

    Param Description

    Discussion

    此方法仅仅是前端返回的初步结果, 并非验证最终结果。获得 result 后还需进一步二次验证, 以校验数据是否伪造。

    shouldUseDefaultSecondaryValidate:

    将要向 API2 发送请求的时候调用此方法。

    Declaration

    - (BOOL)shouldUseDefaultSecondaryValidate:(GT3CaptchaManager *)manager;

    Parameters

    Param Description

    Return Value

    默认返回 YES,表示 manager 使用二次验证默认逻辑。

    gtCaptcha:willSendSecondaryCaptchaRequest:withReplacedRequest:

    通知接收到返回的验证交互结果

    Declaration

    - (void)gtCaptcha:(GT3CaptchaManager *)manager willSendSecondaryCaptchaRequest:(NSURLRequest *)originalRequest withReplacedRequest:(void (^)(NSMutableURLRequest * request))replacedRequest

    Parameters

    Param Description

    Discussion

    请不要修改 requestHandler 执行所在的线程或队列, 否则可能导请求修改失败. 二次验证的请求方式应为 POST , 头部信息应为:

    {"Content-Type":@"application/x-www-form-urlencoded;charset=UTF-8"}

    gtCaptchaUserDidCloseGTView:

    用户主动关闭了验证码界面

    Declaration

    - (void)gtCaptchaUserDidCloseGTView:(GT3CaptchaManager *)manager;

    Parameters

    Param Description

    GT3CaptchaManagerViewDelegate

    gtCaptcha:notifyCaptchaMode:

    通知验证模式

    Declaration

    - (void)gtCaptcha:(GT3CaptchaManager *)manager notifyCaptchaMode:(GT3CaptchaMode)mode;

    Parameters

    Param Description

    gtCaptchaWillShowGTView:

    通知图形界面将要显示

    Declaration

    - (void)gtCaptchaWillShowGTView:(GT3CaptchaManager *)manager;

    Parameters

    Param Description

    gtCaptcha:updateCaptchaStatus:

    更新验证状态

    Declaration

    - (void)gtCaptchaWillShowGTView:(GT3CaptchaManager *)manager;

    Parameters

    Param Description

    gtCaptcha:updateCaptchaViewWithFactor:to:timeInterval:

    更新验证视图

    Declaration

    - (void)gtCaptcha:(GT3CaptchaManager *)manager updateCaptchaViewWithFactor:(CGFloat)fromValue to:(CGFloat)toValue timeInterval:(NSTimeInterval)timeInterval;

    Parameters

    Param Description

    GT3CaptchaManagerStatisticDelegate

    略, 请阅读头文件注视

    GT3AsyncTaskProtocol

    executeRegisterTaskWithCompletion:

    用于自定义验证注册的任务

    Declaration

    - (void)executeRegisterTaskWithCompletion:(void(^)(GT3RegisterParameter * _Nullable params, GT3Error * _Nullable error))completion;

    Parameters

    Param Description

    Seealso

    GT3RegisterParameter

    executeValidationTaskWithValidateParam:completion:

    用于自定义验证结果校验的任务

    Declaration

    - (void)executeValidationTaskWithValidateParam:(GT3ValidationParam *)param completion:(void(^)(BOOL validationResult, GT3Error * _Nullable error))completion;

    Parameters

    Param Description

    Property

    captchaManager

    验证管理器

    Declaration

    @property (nonatomic, readonly, strong) GT3CaptchaManager *captchaManager;

    Seealso

    GT3CaptchaManager

    delegate

    验证按钮代理

    Declaration

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

    captchaState

    验证状态

    Declaration

    @property (nonatomic, readonly, assign) GT3CaptchaState captchaState;

    captchaEdgeInsets

    定义容器视图边距

    Declaration

    @property (nonatomic, assign) UIEdgeInsets captchaEdgeInsets;

    tipsDict

    定义各种验证状态下按钮上的提示文案

    Declaration

    @property (nonatomic, strong) NSDictionary<NSString *, NSAttributedString *> *tipsDict;

    Discussion

    字典请使用以下键名, 与 GT3CaptchaState 一一对应

    'inactive', 'active', 'initial', 'waiting', 'collecting', 'computing', 'success', 'fail', 'error'.

    Seealso

    GT3CaptchaState

    mainColor

    The background color of CAPTCHA widget.

    Declaration

    @property (nonatomic, strong) UIColor *mainColor;

    borderWidth

    Define width for CAPTCHA widget border. Defaults to 1.0. Animatable.

    Declaration

    @property (nonatomic, assign) CGFloat *borderWidth;

    cornerRadius

    Define CAPTCHA widget corner radius. Defaults to 3.0. Animatable.

    Declaration

    @property (nonatomic, assign) CGFloat *cornerRadius;

    indicatorColor

    定义验证状态指示器的颜色

    Declaration

    @property (nonatomic, strong) UIColor *indicatorColor;

    borderColor

    Define color for CAPTCHA widget border. Defaults to 0xcccccc. Animatable.

    Declaration

    @property (nonatomic, strong) UIColor *borderColor;

    Method

    initWithFrame:captchaManager:

    初始化并返回一个新的规定了尺寸的 GT3CaptchaButton 实例对象

    Declaration

    - (instancetype)initWithFrame:(CGRect)frame captchaManager:(GT3CaptchaManager *)captchaManager;

    Parameters

    Param Description
    - (void)startCaptcha;

    Discussion

    根据验证状态, 在 GTCaptchaManager 内部调用实例方法 startGTCaptchaWithAnimated: , requestGTCaptcha , showGTViewIfRegiested

    stopCaptcha

    终止验证

    Declaration

    - (void)startCaptcha;

    resetCaptcha

    重置验证

    Declaration

    - (void)stopCaptcha;

    updateTitleLabel:

    立即更新当前的验证提示标题

    Declaration

    - (void)updateTitleLabel:(NSAttributedString *)title;

    Parameters

    Param Description

    GT3CaptchaManager

    Property

    delegate

    验证管理的代理方法

    Declaration

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

    viewDelegate

    验证视图代理

    Declaration

    @property (nonatomic, weak) id<GT3CaptchaManagerViewDelegate> viewDelegate;

    statisticDelegate

    验证统计代理

    Declaration

    @property (nonatomic, weak) id<GT3CaptchaManagerStatisticDelegate> statisticDelegate;

    captchaState

    验证状态

    Declaration

    @property (nonatomic, readonly) GT3CaptchaState captchaState;

    isShowing

    图形验证的展示状态

    Declaration

    @property (nonatomic, readonly) BOOL isShowing;

    API_1

    获取启动验证参数的接口

    Declaration

    @property (nonatomic, readonly) NSURL *API_1;

    API_2

    进行二次验证的接口

    Declaration

    @property (nonatomic, readonly) NSURL *API_2;

    gt_captcha_id

    本次验证会话的验证ID

    Declaration

    @property (nonatomic, readonly, strong) NSString *gt_captcha_id;

    gt_challenge

    本次验证的会话的流水号

    Declaration

    @property (nonatomic, readonly, strong) NSString *gt_challenge;

    gt_success_code

    当前验证的服务状态

    Declaration

    @property (nonatomic, readonly, strong) NSNumber *gt_success_code;

    Discussion

    1正常/0宕机

    maskColor

    验证背景颜色

    Declaration

    @property (nonatomic, strong) UIColor *maskColor;

    Method

    sdkVersion

    SDK版本号

    Declaration

    + (NSString *)sdkVersion;

    sharedGTManager

    验证单例

    Declaration

    + (instancetype)sharedGTManager;

    initWithAPI1:API2:timeout:

    验证初始化方法

    Declaration

    - (instancetype)initWithAPI1:(NSString *)api_1
    API2:(NSString *)api_2
    timeout:(NSTimeInterval)timeout NS_DESIGNATED_INITIALIZER;

    Parameters

    Param Description

    Discussion

    当希望取消正在执行的 NSURLSessionDataTask 时,调用此方法

    configureGTest:challenge:success:withAPI2:

    自定义配置验证方法

    Declaration

    - (void)configureGTest:(NSString *)gt_public_key
    challenge:(NSString *)gt_challenge
    success:(NSNumber *)gt_success_code
    withAPI2:(NSString *)api_2;

    Parameters

    Param Description

    Discussion

    该方法已抛弃。请使用 registerCaptchaWithCustomAsyncTask:completion: 来自定义 API1 和 API2 请求流程。

    同一个challenge只能使用在同一次验证会话中,如果使用该方法配置验证参数,需要开发者自己控制对 startGTCaptchaWithAnimated: 的调用,以避免在一次验证会话中多次访问该方法。

    registerCaptcha:

    注册验证

    Declaration

    - (void)registerCaptcha:(GT3CaptchaDefaultBlock)completionHandler;

    Parameters

    Param Description

    Seealso

    GT3CaptchaDefaultBlock

    registerCaptchaWithCustomAsyncTask:completion:

    注册验证,并且自定义 API1 及 API2 流程

    Declaration

    - (void)registerCaptchaWithCustomAsyncTask:(id<GT3AsyncTaskProtocol>)customAsyncTask completion:(GT3CaptchaDefaultBlock)completionHandler;

    Parameters

    Param Description

    startGTCaptchaWithAnimated:

    开始验证

    Declaration

    - (void)startGTCaptchaWithAnimated:(BOOL)animated;

    Parameters

    Param Description
    - (void)resetGTCaptcha;

    Discussion

    内部实现是先调用 stopGTCaptcha , 在主线程延迟0.3秒后, 执行 startCaptcha 方法, 且只有在 captchaState GT3CaptchaStateFail , GT3CaptchaStateError ,
    GT3CaptchaStateSuccess , GT3CaptchaStateCancel 才会有效。

    执行完后, 状态为 GT3CaptchaStateInit

    closeGTViewIfIsOpen

    若验证显示则关闭验证界面

    Declaration

    - (void)closeGTViewIfIsOpen;

    getCookieValue:

    获取cookie value

    Declaration

    - (NSString *)getCookieValue:(NSString *)cookieName;

    Parameters

    Param Description

    useGTViewWithTimeout:

    配置 GTView 资源请求超时时长,以秒为单位

    Declaration

    - (void)useGTViewWithTimeout:(NSTimeInterval)timeout;

    Parameters

    Param Description

    useGTViewWithCornerRadius:

    设置图形验证的圆角大小

    Declaration

    - (void)useGTViewWithCornerRadius:(CGFloat)cornerRadius;

    Parameters

    Param Description

    useGTViewWithParams:

    验证标题

    Declaration

    - (void)useGTViewWithParams:(NSDictionary *)params;

    Parameters

    Param Description

    默认不开启. 字符长度不能超过28, 一个中文字符为两个2字符长度.

    useGTViewWithInterfaceOrientation:

    验证视图支持的方向

    Declaration

    - (void)useGTViewWithInterfaceOrientation:(UIInterfaceOrientationMask)supportOrientation;

    Parameters

    Param Description

    useAnimatedAcitvityIndicator:withIndicatorType:

    验证视图高度约束

    Declaration

    - (void)useAnimatedAcitvityIndicator:(GT3IndicatorAnimationViewBlock)animationBlock
    withIndicatorType:(GT3ActivityIndicatorType)type

    Parameters

    Param Description

    Discussion

    为了能方便的调试动画,真机调试模拟低速网络, Settings->Developer->Status->Enable->Edge(😂)

    useVisualViewWithEffect:

    配置背景模糊

    Declaration

    - (void)useVisualViewWithEffect:(UIBlurEffect *)blurEffect;

    Parameters

    Param Description

    useServiceNode:

    切换验证服务集群节点

    Declaration

    - (void)useServiceNode:(GT3CaptchaServiceNode)node;

    Parameters

    Param Description

    默认中国节点。使用其他节点需要使用相应的配置,否则无法正确访问验证服务。使用该方法前,请向极验技术支持充分了解极验的服务集群节点。

    Seealso

    详细见 GT3CaptchaServiceNode

    disableSecurityAuthentication:

    控制使用HTTPS协议请求验证

    Declaration

    - (void)disableSecurityAuthentication:(BOOL)disable;

    Parameters

    Param Description

    disableBackgroundUserInteraction:

    控制验证背景交互事件

    Declaration

    - (void)disableBackgroundUserInteraction:(BOOL)disable;

    Parameters

    Param Description

    enableNetworkReachability:

    控制内部的网络可达性检测

    Declaration

    - (void)enableNetworkReachability:(BOOL)enable;

    Parameters

    Param Description

    GT3RegisterParameter

    Property

    gt

    验证ID(gt)

    Declaration

    @property (nonatomic, strong) NSString *gt;

    challenge

    验证流水号

    Declaration

    @property (nonatomic, strong) NSString *challenge;

    success

    验证当机状态。@(1) 为正常, @(0) 为宕机。

    Declaration

    @property (nonatomic, strong) NSNumber *success;

    GT3ValidationParam

    Property

    code

    验证初步判定结果。@”1” 通过, @”0” 未通过。

    Declaration

    @property (nonatomic, strong) NSString *code;

    result

    验证结果校验数据。使用该数据,通过 validate 接口进行结果校验,以获得最终验证结果。

    Declaration

    @property (nullable, nonatomic, strong) NSDictionary *result;

    message

    附带的消息。

    Declaration

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

    GT3Error

    极验封装的错误对象, 用于方便构造和返回特别信息

    GT3ErrorType

    极验定义的错误类型

    Declaration

    typedef NS_ENUM(NSUInteger, GT3ErrorType) {
    /** 用户中断验证导致 */
    GT3ErrorTypeUser,
    /** 服务端返回错误 */
    GT3ErrorTypeServer,
    /** 内部网络抛出错误类型 */
    GT3ErrorTypeNetWorking,
    /** 内部浏览器抛出的错误类型 */
    GT3ErrorTypeWebView,
    /** 从前端库抛出的错误类型 */
    GT3ErrorTypeJavaScript,
    /** 内部解码错误类型 */
    GT3ErrorTypeDecode,
    /** 未知错误类型 */
    GT3ErrorTypeUnknown
    };

    Property

    metaData

    发生错误时接收到的元数据, 没有数据则为nil

    Declaration

    @property (nonatomic, readonly, strong) NSData * _Nullable metaData;

    gtDescription

    极验的额外错误信息

    Declaration

    @property (nonatomic, readonly, strong) NSString * gtDescription;

    originalError

    原始的error

    Declaration

    @property (nonatomic, readonly, strong) NSError * _Nullable originalError;

    Method

    errorWithDomainType:code:userInfo:withGTDesciption:

    通过提供的详细的参数初始化GT3Error

    Declaration

    + (instancetype)errorWithDomainType:(GT3ErrorType)type code:(NSInteger)code userInfo:(nullable NSDictionary *)dict withGTDesciption:(NSString *)description;

    Parameters

    Param Description

    errorWithDomainType:originalError:withGTDesciption:

    基于提供的NSError封装成GT3Error

    Declaration

    + (instancetype)errorWithDomainType:(GT3ErrorType)type originalError:(NSError *)originalError withGTDesciption:(NSString *)description;

    Parameters

    Param Description

    GT3CaptchaState

    极验验证状态的枚举量

    Declaration

    typedef NS_ENUM(NSInteger, GT3CaptchaState) {
    /** 验证未激活 */
    GT3CaptchaStateInactive,
    /** 验证激活 */
    GT3CaptchaStateActive,
    /** 验证初始化中 */
    GT3CaptchaStateInitial,
    /** 验证检测数据中 */
    GT3CaptchaStateCollecting,
    /** 验证等待提交中 */
    GT3CaptchaStateWaiting,
    /** 验证结果判定中*/
    GT3CaptchaStateComputing,
    /** 验证通过*/
    GT3CaptchaStateSuccess,
    /** 验证失败*/
    GT3CaptchaStateFail,
    /** 验证发生错误*/
    GT3CaptchaStateError
    };

    GT3CaptchaServiceNode

    验证集群节点

    Declaration

    typedef NS_ENUM(NSInteger, GT3CaptchaServiceNode) {
    /** 中国服务集群 */
    GT3CaptchaServiceNodeCN = 0,
    /** 中国服务集群(支持 IPv6)*/
    GT3CaptchaServiceNodeCN_IPv6,
    /** 北美亚马逊云服务集群 */
    GT3CaptchaServiceNodeNA,
    /** 北美谷歌云服务集群,该节点已停止使用 */
    GT3CaptchaServiceNodeNG,
    /** 默认服务集群 */
    GT3CaptchaServiceNodeDefault = GT3CaptchaServiceNodeCN
    };

    GT3CaptchaMode

    验证模式枚举量

    Declaration

    typedef NS_ENUM(NSInteger, GT3CaptchaMode) {
    /** 验证默认模式*/
    GT3CaptchaModeDefault,
    /** 验证宕机模式*/
    GT3CaptchaModeFailback
    };

    GT3SecondaryCaptchaPolicy

    视图上结果的更新策略

    Declaration

    typedef NS_ENUM(NSInteger, GT3SecondaryCaptchaPolicy) {
    /** 二次验证通过 */
    GT3SecondaryCaptchaPolicyAllow,
    /** 二次验证拒绝 */
    GT3SecondaryCaptchaPolicyForbidden
    };

    GT3LanguageType

    语言选项

    Declaration

    typedef NS_ENUM(NSInteger, GT3LanguageType) {
    /** Simplified Chinese 简体中文 */
    GT3LANGTYPE_ZH_CN = 0,
    /** Traditional Chinese 繁体中文 */
    GT3LANGTYPE_ZH_TW,
    /** Traditional Chinese 繁体中文 */
    GT3LANGTYPE_ZH_HK,
    /** Korean 韩语 */
    GT3LANGTYPE_KO_KR,
    /** Japenese 日语 */
    GT3LANGTYPE_JA_JP,
    /** English 英语 */
    GT3LANGTYPE_EN,
    /** Indonesian 印度尼西亚语 */
    GT3LANGTYPE_ID,
    /** Arabic 阿拉伯语 */
    GT3LANGTYPE_AR,
    /** German 德语 */
    GT3LANGTYPE_DE,
    /** Spanish 西班牙语 */
    GT3LANGTYPE_ES,
    /** French 法语 */
    GT3LANGTYPE_FR,
    /** Portuguese 葡萄牙语 */
    GT3LANGTYPE_PT_PT,
    /** Russian 俄语 */
    GT3LANGTYPE_RU,
    /** System language 跟随系统语言*/
    GT3LANGTYPE_AUTO = 999
    };

    GT3ActivityIndicatorType

    活动指示器类型

    Declaration

    typedef NS_ENUM(NSInteger, GT3ActivityIndicatorType) {
    /** System Indicator Type */
    GT3IndicatorTypeSystem = 0,
    /** Geetest Defualt Indicator Type */
    GT3IndicatorTypeDefault,
    /** Custom Indicator Type */
    GT3IndicatorTypeCustom,
    };

    Parameters

    Param Description

    Declaration

    typedef void(^GT3CaptchaDefaultBlock)(void);

    GT3IndicatorAnimationViewBlock

    自定义状态指示器的动画实现block

    Declaration

    typedef void(^GT3IndicatorAnimationViewBlock)(CALayer *layer, CGSize size, UIColor *color);

    Parameters

    Param Description