iOS SDK API
GTCaptcha4SessionTaskDelegate
Verification session task delegate protocol
gtCaptchaSession:didReceive:result:
Callback for the result parameters of the verification session.
Declaration
- (void)gtCaptchaSession:(GTCaptcha4Session *)captchaSession
didReceive:(NSString *)status
result:(nullable NSDictionary *)result;
Parameters
| Param | Description |
|---|---|
| captchaSession | Verification session |
| status | Status code. @"0"/@"1": Incomplete/Complete. When status is @"1", it indicates success, and the result needs secondary verification. |
| result | Result verification parameters. |
Discussion
After obtaining the verification result parameters, they need to be submitted to the business server to complete parameter verification. result example:
{
pass_token = "eb6d2e064524ae96ddc99a0e6e15f95dbb234008d108f0db269f27d426bcf3c6";
gen_time = "1660894030";
captcha_output = "fI9I34MDjVi10gJO_EqXwNpN8hK0rYLEPVWSDE4W6kc1umDoTHIlD_t6YQNNpPG2tJlKR8he6WFWkkllU8goGeNVNOzhqmAm256BpK8qAEHNrOjHzkNagfIcx_A21ssPrG6YlnnHFx3PfBnbrn5fb2aKDIi0I5xmCUjxq0dsFuANLIQVtllMjkJ7-1l_j-Wz";
captcha_id = "647f5ed2ed8acb4be36784e01556bb71";
lot_number = "0861c607d519469b9117d0c6dd551fe3";
}
gtCaptchaSession:didReceiveError:
Callback for errors occurring during the verification session.
Declaration
- (void)gtCaptchaSession:(GTCaptcha4Session *)captchaSession
didReceiveError:(GTC4Error *)error;
Parameters
| Param | Description |
|---|---|
| captchaSession | Verification session |
| error | Error description object |
Seealso
GTCaptcha4Session
Verification session
delegate
Verification session task delegate.
Declaration
@property (nonatomic, weak) id<GTCaptcha4SessionTaskDelegate> delegate;
captchaID
Verification ID of the current session.
Declaration
@property (nonnull, readonly, nonatomic, strong) NSString *captchaID;
challenge
Serial number of the current verification session.
Declaration
@property (nullable, readonly, nonatomic, strong) NSString *challenge;
configuration
Configuration of the current verification session.
Declaration
@property (nonnull, readonly, nonatomic, strong) GTCaptcha4SessionConfiguration *configuration;
sessionWithCaptchaID:
Create a new verification session instance.
Declaration
+ (instancetype)sessionWithCaptchaID:(NSString *)captchaID;
Parameters
| Param | Description |
|---|---|
| captchaID | Verification ID |
Return Value
A new GTCaptcha4Session instance
sessionWithCaptchaID:configuration:
Create a new verification session instance.
Declaration
+ (instancetype)sessionWithCaptchaID:(NSString *)captchaID
configuration:(nullable GTCaptcha4SessionConfiguration *)configuration;
| Param | Description |
|---|---|
| captchaID | Verification ID |
| configuration | Session configuration |
Return Value
A new GTCaptcha4Session instance
initWithCaptchaID:
Create a new verification session instance.
Declaration
- (instancetype)initWithCaptchaID:(NSString *)captchaID;
Parameters
| Param | Description |
|---|---|
| captchaID | Verification ID |
Return Value
A new GTCaptcha4Session instance
initWithCaptchaID:configuration:
Create a new verification session instance.
Declaration
- (instancetype)initWithCaptchaID:(NSString *)captchaID
configuration:(nullable GTCaptcha4SessionConfiguration *)configuration;
| Param | Description |
|---|---|
| captchaID | Verification ID |
| configuration | Session configuration |
Return Value
A new GTCaptcha4Session instance
verify
Start verification.
Declaration
- (void)verify;
cancel
Cancel verification.
Declaration
- (void)cancel;
sdkVersion
Get the SDK version number.
Declaration
+ (NSString *)sdkVersion;
GTCaptcha4SessionConfiguration
Verification session configuration
GTC4UserInterfaceStyle
Verification interface style.
Declaration
typedef NS_ENUM(NSInteger, GTC4UserInterfaceStyle) {
/** Follow system style */
GTC4UserInterfaceStyleSystem = 0,
/** Light style */
GTC4UserInterfaceStyleLight,
/** Dark style */
GTC4UserInterfaceStyleDark,
/** Default style */
GTC4UserInterfaceStyleDefault = GTC4UserInterfaceStyleLight
};
resourcePath
The complete path for remote access to static resources, default is empty.
Declaration
@property (nullable, nonatomic, strong) NSString *resourcePath;
protocol
The protocol used for remote access to static resources, default is @“https”.
Declaration
@property (nonatomic, strong) NSString *protocol;
userInterfaceStyle
The interface and status bar style, default is plain white.
Declaration
@property (nonatomic, assign) GTC4UserInterfaceStyle userInterfaceStyle;
backgroundColor
Background color, default is transparent.
Declaration
@property (nonatomic, strong) UIColor *backgroundColor;
debugEnable
Debug mode switch, default is off.
Declaration
@property (nonatomic, assign) BOOL debugEnable;
backgroundUserInteractionEnable
Interaction with the background, default is enabled.
Declaration
@property (nonatomic, assign) BOOL backgroundUserInteractionEnable;
timeout
Request timeout duration, default is 8 seconds.
Declaration
@property (nonatomic, assign) NSTimeInterval timeout;
language
Language, default follows the system. For specific languages, refer to language short codes.
Declaration
@property (nonatomic, strong) NSString *language;
supportedInterfaceOrientations
Supported screen orientations.
Declaration
@property (assign, nonatomic) UIInterfaceOrientationMask supportedInterfaceOrientations;
additionalParameter
Additional parameters, default is empty. The parameters will be assembled and submitted to engagelab.
Declaration
@property (nullable, nonatomic, strong) NSDictionary *additionalParameter;
Discussion
The supported key-value list is as follows:
| Key | Type | Description | Default Value |
|---|---|---|---|
@"loading" |
NSString |
Custom loading state indicator, relative path of the loading resource for WebView loading html. Setting an empty string cancels the loading. | @"./gt4-loading.gif" |
@"rem" |
NSNumber |
Set the overall scaling ratio of the verification code. | @(1) |
@"hideBar" |
NSArray<NSString *> * |
Hide the close button and refresh button on subsequent verification screens. Setting @[@"close", @"refresh"] hides the close and refresh buttons. |
@[] |
@"nextWidth" |
NSString |
The width of the verification code popup, with units such as @"300px". |
nil |
@"riskType" |
NSString |
Specify the verification type in conjunction with risk control integration. | nil |
@"hideSuccess" |
NSNumber |
Hide the verification success popup, @(0)/@(1) for not hiding or hiding. |
@(0) |
Sample Code
#define captchaID @"1234567890abcdef"
GTCaptcha4SessionConfiguration *config = [GTCaptcha4SessionConfiguration defaultConfiguration];
NSMutableDictionary *params = [@{} mutableCopy];
[params setValue:@(1.25) forKey:@"rem"]; // Scale up by 1.25 times
[params setValue:@[@"close", @"refresh"] forKey:@"hideBar"]; // Hide close and refresh buttons
[params setValue:@"300px" forKey:@"nextWidth"];
[params setValue:@"click" forKey:@"riskType"]; // Specify smart click verification, consistent with backend configuration
[params setValue:@(1) forKey:@"hideSuccess"]; // Use NSNumber to represent boolean value
[params setValue:@"./gt4-loading.gif" forKey:@"loading"];
config.additionalParameter = params;
GTCaptcha4Session *captchaSession = [GTCaptcha4Session sessionWithCaptchaID:captchaID configuration:config];
...
defaultConfiguration
Obtain 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;
}
Error
Error description object
/// Invalid parameter. Please check the input parameters.
FOUNDATION_EXPORT NSString * const GTC4ErrorCodeInvalidParameter;
/// Operation failed. Check the detailed description.
FOUNDATION_EXPORT NSString * const GTC4ErrorCodeOperationFail;
/// Resource missing. Please check if the GTCaptcha4.bundle file is complete.
FOUNDATION_EXPORT NSString * const GTC4ErrorCodeMissedResource;
/// User canceled the verification.
FOUNDATION_EXPORT NSString * const GTC4ErrorCodeUserDidCancel;
/// Failed to load the file. Please check if the complete GTCaptcha4.bundle file is imported or if the configured remote static resource is accessible.
FOUNDATION_EXPORT NSString * const GTC4ErrorCodeLoadFileFailure;
/// Loading timeout.
FOUNDATION_EXPORT NSString * const GTC4ErrorCodeTimeout;
/// Failed to execute Javascript script.
FOUNDATION_EXPORT NSString * const GTC4ErrorCodeEvaluatingJavascriptFail;
/// Javascript returned 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. Can be used for matching and handling.
Declaration
@property (readonly, nonatomic, strong) NSString *code;
Seealso
Refer to the error code list above.
msg
Error message. Can be used for user interface display.
Declaration
@property (readonly, nonatomic, strong) NSString *msg;
desc
Detailed error description. Used for detailed troubleshooting.
Declaration
@property (readonly, nonatomic, strong) NSDictionary *desc;
Discussion
Can be used to support operational issues in user verification.









