>

iOS

GTCaptcha4SessionTaskDelegate

Captcha Session Task Delegate

gtCaptchaSession:didReceive:result:

Callback result parameters of captcha session.

Declaration

- (void)gtCaptchaSession:(GTCaptcha4Session *)captchaSession

didReceive:(NSString *)status

result:(nullable NSDictionary *)result;

Parameters

Param Description
captchaSession Captcha session
status Status code. @ “0”/@ “1”: Not finished/finished. When status is @ “1”, it is successful, and the result needs to be secondary validated.
result Result verification parameters.

Discussion

After getting the parameters of verification results, they need to be submitted to the business server to complete the verification of parameters.

Result sample:

{ "challenge" : "19080ae5-fe79-4431-9c78-4ee8e0dec798", "captcha_id" : "c62d0f270240799b3113b0a5787ead55"}

gtCaptchaSession:didReceiveError:

Callback errors that occurred in the captcha session.

Declaration

- (void)gtCaptchaSession:(GTCaptcha4Session *)captchaSession

didReceiveError:(GTC4Error *)error;

Parameters

Param Description
captchaSession Captcha session
error Error description object

See also GTC4Error

GTCaptcha4Session

Captcha session

delegate

Captcha session task delegate.

Declaration

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

captchaID

The captcha ID of the current captcha session.

Declaration

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

challenge

The serial number of the current captcha session.

Declaration

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

configuration

Configuration of the current captcha session.

Declaration

@property (nonnull, readonly, nonatomic, strong) GTCaptcha4SessionConfiguration *configuration;

sessionWithCaptchaID:

Create a new captcha session instance.

Declaration

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

Parameters

Param Description
captchaID Captcha ID

Return Value is a new GTCaptcha4Session instance

sessionWithCaptchaID:configuration:

Create a new captcha session instance.

Declaration

+ (instancetype)sessionWithCaptchaID:(NSString *)captchaID

configuration:(nullable GTCaptcha4SessionConfiguration *)configuration;
Param Description
captchaID Captcha ID
configuration Configure session

Return Value is a new GTCaptcha4Session instance

initWithCaptchaID:

Create a new captcha session instance.

Declaration

- (instancetype)initWithCaptchaID:(NSString *)captchaID;
Param Description
captchaID Captcha ID

Return Value is a new GTCaptcha4Session instance

initWithCaptchaID:configuration:

Create a new captcha session instance.

Declaration

- (instancetype)initWithCaptchaID:(NSString *)captchaID

configuration:(nullable GTCaptcha4SessionConfiguration *)configuration;
Param Description
captchaID Captcha ID
configuration Configure session

Return Value is a new GTCaptcha4Session instance

verify

Start verification

Declaration

- (void)verify;

cancel

Cancel verification

Declaration

- (void)verify;

sdkVersion

Obtain the SDK version number.

Declaration

+ (NSString *)sdkVersion;

GTCaptcha4SessionConfiguration

Captcha session configuration

GTC4UserInterfaceStyle

Verify the interface style.

Declaration

typedef NS_ENUM(NSInteger, GTC4UserInterfaceStyle) {

/** Follow system */
GTC4UserInterfaceStyleSystem = 0,

/** Light */
GTC4UserInterfaceStyleLight,

/** Dark */
GTC4UserInterfaceStyleDark,

/** Default */
GTC4UserInterfaceStyleDefault = GTC4UserInterfaceStyleLight

};

GTC4DisplayStyle

Captcha Display Style

Declaration

typedef NS_ENUM(NSInteger, GTC4DisplayStyle) {

/** Center */
GTC4DisplayStyleCenter = 0,

/** Bottom */
GTC4DisplayStyleBottom,

/** Default*/
GTC4DisplayStyleDefault = GTC4DisplayStyleCenter,
};

resourcePath

The full path of remote access to static resources, which is empty by default.

Declaration

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

protocol

Protocol for remote access to static resources, default is @ “https”.

Declaration

@property (nonatomic, strong) NSString *protocol;

userInterfaceStyle

Interface style is white by default.

Declaration

@property (nonatomic, assign) GTC4UserInterfaceStyle userInterfaceStyle;

displayStyle

The display style of the interface is centered by default.

Declaration

@property (nonatomic, assign) GTC4DisplayStyle displayStyle;

backgroundColor

The background color is transparent by default.

Declaration

@property (nonatomic, strong) UIColor *backgroundColor;

debugEnable

Debug is disabled by default.

Declaration

@property (nonatomic, assign) BOOL debugEnable;

backgroundUserInteractionEnable

Background user interaction is enabled by default.

Declaration

@property (nonatomic, assign) BOOL backgroundUserInteractionEnable;

timeout

Request timeout is 8 seconds by default.

Declaration

@property (nonatomic, assign) NSTimeInterval timeout;

language

Language is the system language by default. Please refer to the language short code for setting the language.

Declaration

@property (nonatomic, strong) NSString *language;

additionalParameter

Additional parameters, which are empty by default. Parameters will be assembled and submitted to the GeeTest.

Declaration

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

defaultConfiguration

Get a default configuration.

Declaration

+ (GTCaptcha4SessionConfiguration *)defaultConfiguration;

Return Value

+ (GTCaptcha4SessionConfiguration *)defaultConfiguration {

GTCaptcha4SessionConfiguration *config = [[GTCaptcha4SessionConfiguration alloc] init];
config.debugEnable = NO;
config.timeout = 8.0;
config.language = [GTC4Utils systemLanguage];
config.protocol = @"https";
config.userInterfaceStyle = GTC4UserInterfaceStyleDefault;
config.displayStyle = GTC4DisplayStyleDefault;
config.backgroundColor = [UIColor clearColor];
config.backgroundUserInteractionEnable = YES;

return config;

}

GTC4Error

Error description object

/// Illegal parameter. Please check the parameters you entered. 

FOUNDATION_EXPORT NSString * const GTC4ErrorCodeInvalidParameter;

/// Operation failed. Check the description in detail.

FOUNDATION_EXPORT NSString * const GTC4ErrorCodeOperationFail;

/// Lack of resources. Please check if the `GTCaptcha4.bundle` file is imported correctly.

FOUNDATION_EXPORT NSString * const GTC4ErrorCodeMissedResource;



/// Verification is canceled by the user.

FOUNDATION_EXPORT NSString * const GTC4ErrorCodeUserDidCancel;



/// Failed to load file. Please check if the `GTCaptcha4.bundle` file is complete or if the configured remote static resource is accessible.

FOUNDATION_EXPORT NSString * const GTC4ErrorCodeLoadFileFailure;



/// Load timeout.

FOUNDATION_EXPORT NSString * const GTC4ErrorCodeTimeout;

/// Evaluating javascript script fail.

FOUNDATION_EXPORT NSString * const GTC4ErrorCodeEvaluatingJavascriptFail;



/// Javascript returns an error.

FOUNDATION_EXPORT NSString * const GTC4ErrorCodeJavascriptError;

/// WebView memory warning.

FOUNDATION_EXPORT NSString * const GTC4ErrorCodeWebViewMemoryWarning;



/// Unknown error.

FOUNDATION_EXPORT NSString * const GTC4ErrorCodeUnknown;

code

Error code, and can be used for matching processing.

Declaration

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

See also the error code list above

msg

Error message which can be used to display on user interface.

Declaration

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

desc

Detailed description of the error, which is used to troubleshoot problems in detail.

Declaration

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

Discussion

Support users’ operational problems with captcha.

Was this helpful?
Send