> >

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:

{
pass_token = "eb6d2e064524ae96ddc99a0e6e15f95dbb234008d108f0db269f27d426bcf3c6";
gen_time = "1660894030";
captcha_output = "fI9I34MDjVi10gJO_EqXwNpN8hK0rYLEPVWSDE4W6kc1umDoTHIlD_t6YQNNpPG2tJlKR8he6WFWkkllU8goGeNVNOzhqmAm256BpK8qAEHNrOjHzkNagfIcx_A21ssPrG6YlnnHFx3PfBnbrn5fb2aKDIi0I5xmCUjxq0dsFuANLIQVtllMjkJ7-1l_j-Wz";
captcha_id = "647f5ed2ed8acb4be36784e01556bb71";
lot_number = "0861c607d519469b9117d0c6dd551fe3";
}

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

};

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

User interface and statusBar style, which is white by default.

Declaration

@property (nonatomic, assign) GTC4UserInterfaceStyle userInterfaceStyle;

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;

supportedInterfaceOrientations

The supported interface orientations.

Declaration

@property (assign, nonatomic) UIInterfaceOrientationMask supportedInterfaceOrientations;

additionalParameter

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

Declaration

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

Discussion

Supported key-values:

Key Type Description Default Value
@"loading" NSString Status indicator of custom loading, the relative path of loading resource of html is loaded by Webview. The empty string refers to cancel the effect of loading @"./gt4-loading.gif"
@"rem" NSNumber Set the overall scaling ratio of the captcha @(1)
@"hideBar" NSArray<NSString *> * Hide the “close” button and “refresh” button. Hides close and refresh button, if set @[@"close", @"refresh"]. @[]
@"nextWidth" NSString The width of the captcha pop-up window. The unit is needed, such as @”300px”. nil
@"riskType" NSString Conbined with Direct Platform Integration, specify the CAPTCHA form. nil
@"hideSuccess" NSNumber Hide the popup window of verification success. @(0)

Sample Code

#define captchaID @"1234567890abcdef"

GTCaptcha4SessionConfiguration *config = [GTCaptcha4SessionConfiguration defaultConfiguration];

NSMutableDictionary *params = [@{} mutableCopy];
[params setValue:@(1.25) forKey:@"rem"]; // Zoom 1.25x
[params setValue:@[@"close", @"refresh"] forKey:@"hideBar"]; // Hide the "close" button and "refresh" button
[params setValue:@"300px" forKey:@"nextWidth"];
[params setValue:@"click" forKey:@"riskType"]; // specify a captcha type, it has to consistent with the back-end configuration
[params setValue:@(1) forKey:@"hideSuccess"]; // using NSNumber for boolean values
[params setValue:@"./gt4-loading.gif" forKey:@"loading"];

config.additionalParameter = params;

GTCaptcha4Session *captchaSession = [GTCaptcha4Session sessionWithCaptchaID:captchaID configuration:config];
...

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.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