logoDocument
Search
Login

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;
              
              - (void)gtCaptchaSession:(GTCaptcha4Session *)captchaSession
              didReceive:(NSString *)status
                  result:(nullable NSDictionary *)result;

            
This code block in the floating window

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"; }
              
              {
    pass_token = "eb6d2e064524ae96ddc99a0e6e15f95dbb234008d108f0db269f27d426bcf3c6";
    gen_time = "1660894030";
    captcha_output = "fI9I34MDjVi10gJO_EqXwNpN8hK0rYLEPVWSDE4W6kc1umDoTHIlD_t6YQNNpPG2tJlKR8he6WFWkkllU8goGeNVNOzhqmAm256BpK8qAEHNrOjHzkNagfIcx_A21ssPrG6YlnnHFx3PfBnbrn5fb2aKDIi0I5xmCUjxq0dsFuANLIQVtllMjkJ7-1l_j-Wz";
    captcha_id = "647f5ed2ed8acb4be36784e01556bb71";
    lot_number = "0861c607d519469b9117d0c6dd551fe3";
}

            
This code block in the floating window

gtCaptchaSession:didReceiveError:

Callback for errors occurring during the verification session.

Declaration

- (void)gtCaptchaSession:(GTCaptcha4Session *)captchaSession didReceiveError:(GTC4Error *)error;
              
              - (void)gtCaptchaSession:(GTCaptcha4Session *)captchaSession
         didReceiveError:(GTC4Error *)error;

            
This code block in the floating window

Parameters

Param Description
captchaSession Verification session
error Error description object

Seealso

Error

GTCaptcha4Session

Verification session

delegate

Verification session task delegate.

Declaration

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

            
This code block in the floating window

captchaID

Verification ID of the current session.

Declaration

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

            
This code block in the floating window

challenge

Serial number of the current verification session.

Declaration

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

            
This code block in the floating window

configuration

Configuration of the current verification session.

Declaration

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

            
This code block in the floating window

sessionWithCaptchaID:

Create a new verification session instance.

Declaration

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

            
This code block in the floating window

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;
              
              + (instancetype)sessionWithCaptchaID:(NSString *)captchaID
                       configuration:(nullable GTCaptcha4SessionConfiguration *)configuration;

            
This code block in the floating window
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;
              
              - (instancetype)initWithCaptchaID:(NSString *)captchaID;

            
This code block in the floating window

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;
              
              - (instancetype)initWithCaptchaID:(NSString *)captchaID
                    configuration:(nullable GTCaptcha4SessionConfiguration *)configuration;

            
This code block in the floating window
Param Description
captchaID Verification ID
configuration Session configuration

Return Value

A new GTCaptcha4Session instance

verify

Start verification.

Declaration

- (void)verify;
              
              - (void)verify;

            
This code block in the floating window

cancel

Cancel verification.

Declaration

- (void)cancel;
              
              - (void)cancel;

            
This code block in the floating window

sdkVersion

Get the SDK version number.

Declaration

+ (NSString *)sdkVersion;
              
              + (NSString *)sdkVersion;

            
This code block in the floating window

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 };
              
              typedef NS_ENUM(NSInteger, GTC4UserInterfaceStyle) {
    /** Follow system style */
    GTC4UserInterfaceStyleSystem = 0,
    /** Light style */
    GTC4UserInterfaceStyleLight,
    /** Dark style */
    GTC4UserInterfaceStyleDark,
    /** Default style */
    GTC4UserInterfaceStyleDefault = GTC4UserInterfaceStyleLight
};

            
This code block in the floating window

resourcePath

The complete path for remote access to static resources, default is empty.

Declaration

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

            
This code block in the floating window

protocol

The protocol used for remote access to static resources, default is @“https”.

Declaration

@property (nonatomic, strong) NSString *protocol;
              
              @property (nonatomic, strong) NSString *protocol;

            
This code block in the floating window

userInterfaceStyle

The interface and status bar style, default is plain white.

Declaration

@property (nonatomic, assign) GTC4UserInterfaceStyle userInterfaceStyle;
              
              @property (nonatomic, assign) GTC4UserInterfaceStyle userInterfaceStyle;

            
This code block in the floating window

backgroundColor

Background color, default is transparent.

Declaration

@property (nonatomic, strong) UIColor *backgroundColor;
              
              @property (nonatomic, strong) UIColor *backgroundColor;

            
This code block in the floating window

debugEnable

Debug mode switch, default is off.

Declaration

@property (nonatomic, assign) BOOL debugEnable;
              
              @property (nonatomic, assign) BOOL debugEnable;

            
This code block in the floating window

backgroundUserInteractionEnable

Interaction with the background, default is enabled.

Declaration

@property (nonatomic, assign) BOOL backgroundUserInteractionEnable;
              
              @property (nonatomic, assign) BOOL backgroundUserInteractionEnable;

            
This code block in the floating window

timeout

Request timeout duration, default is 8 seconds.

Declaration

@property (nonatomic, assign) NSTimeInterval timeout;
              
              @property (nonatomic, assign) NSTimeInterval timeout;

            
This code block in the floating window

language

Language, default follows the system. For specific languages, refer to language short codes.

Declaration

@property (nonatomic, strong) NSString *language;
              
              @property (nonatomic, strong) NSString *language;

            
This code block in the floating window

supportedInterfaceOrientations

Supported screen orientations.

Declaration

@property (assign, nonatomic) UIInterfaceOrientationMask supportedInterfaceOrientations;
              
              @property (assign, nonatomic) UIInterfaceOrientationMask supportedInterfaceOrientations;

            
This code block in the floating window

additionalParameter

Additional parameters, default is empty. The parameters will be assembled and submitted to engagelab.

Declaration

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

            
This code block in the floating window

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]; ...
              
              #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];
...

            
This code block in the floating window

defaultConfiguration

Obtain a default configuration.

Declaration

+ (GTCaptcha4SessionConfiguration *)defaultConfiguration;
              
              + (GTCaptcha4SessionConfiguration *)defaultConfiguration;

            
This code block in the floating window

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; }
              
              + (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;
}

            
This code block in the floating window

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;
              
              /// 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;

            
This code block in the floating window

code

Error code. Can be used for matching and handling.

Declaration

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

            
This code block in the floating window

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;
              
              @property (readonly, nonatomic, strong) NSString *msg;

            
This code block in the floating window

desc

Detailed error description. Used for detailed troubleshooting.

Declaration

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

            
This code block in the floating window

Discussion

Can be used to support operational issues in user verification.

icon
Contact Sales