logoDocumentación
Buscar
Iniciar sesión

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;

            
Este bloque de código se muestra en una ventana flotante

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";
}

            
Este bloque de código se muestra en una ventana flotante

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;

            
Este bloque de código se muestra en una ventana flotante

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;

            
Este bloque de código se muestra en una ventana flotante

captchaID

Verification ID of the current session.

Declaration

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

            
Este bloque de código se muestra en una ventana flotante

challenge

Serial number of the current verification session.

Declaration

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

            
Este bloque de código se muestra en una ventana flotante

configuration

Configuration of the current verification session.

Declaration

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

            
Este bloque de código se muestra en una ventana flotante

sessionWithCaptchaID:

Create a new verification session instance.

Declaration

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

            
Este bloque de código se muestra en una ventana flotante

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;

            
Este bloque de código se muestra en una ventana flotante
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;

            
Este bloque de código se muestra en una ventana flotante

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;

            
Este bloque de código se muestra en una ventana flotante
Param Description
captchaID Verification ID
configuration Session configuration

Return Value

A new GTCaptcha4Session instance

verify

Start verification.

Declaration

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

            
Este bloque de código se muestra en una ventana flotante

cancel

Cancel verification.

Declaration

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

            
Este bloque de código se muestra en una ventana flotante

sdkVersion

Get the SDK version number.

Declaration

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

            
Este bloque de código se muestra en una ventana flotante

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

            
Este bloque de código se muestra en una ventana flotante

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;

            
Este bloque de código se muestra en una ventana flotante

protocol

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

Declaration

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

            
Este bloque de código se muestra en una ventana flotante

userInterfaceStyle

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

Declaration

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

            
Este bloque de código se muestra en una ventana flotante

backgroundColor

Background color, default is transparent.

Declaration

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

            
Este bloque de código se muestra en una ventana flotante

debugEnable

Debug mode switch, default is off.

Declaration

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

            
Este bloque de código se muestra en una ventana flotante

backgroundUserInteractionEnable

Interaction with the background, default is enabled.

Declaration

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

            
Este bloque de código se muestra en una ventana flotante

timeout

Request timeout duration, default is 8 seconds.

Declaration

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

            
Este bloque de código se muestra en una ventana flotante

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;

            
Este bloque de código se muestra en una ventana flotante

supportedInterfaceOrientations

Supported screen orientations.

Declaration

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

            
Este bloque de código se muestra en una ventana flotante

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;

            
Este bloque de código se muestra en una ventana flotante

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

            
Este bloque de código se muestra en una ventana flotante

defaultConfiguration

Obtain a default configuration.

Declaration

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

            
Este bloque de código se muestra en una ventana flotante

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

            
Este bloque de código se muestra en una ventana flotante

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;

            
Este bloque de código se muestra en una ventana flotante

code

Error code. Can be used for matching and handling.

Declaration

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

            
Este bloque de código se muestra en una ventana flotante

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;

            
Este bloque de código se muestra en una ventana flotante

desc

Detailed error description. Used for detailed troubleshooting.

Declaration

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

            
Este bloque de código se muestra en una ventana flotante

Discussion

Can be used to support operational issues in user verification.

icon
Contacto