iOS
iOS SDK API reference and configuration guide.
GeeLabCaptchaSessionTaskDelegate
The verification-session task delegate protocol.
geelabCaptchaSession:didReceive:result:
Receives the verification-session result parameters.
Declaration
- (void)geelabCaptchaSession:(GeeLabCaptchaSession *)captchaSession
didReceive:(NSString *)status
result:(nullable NSDictionary *)result;Parameters
| Parameter | Description |
|---|---|
| captchaSession | The verification session. |
| status | Status code. @"0" / @"1" indicates incomplete / completed. When the value is @"1", verification succeeded and the result must be verified again by your server. |
| result | Verification result parameters. |
Discussion
Submit the result parameters to your business server for secondary verification. Example result:
{
pass_token = "eb6d2e064524ae96ddc99a0e6e15f95dbb234008d108f0db269f27d426bcf3c6";
gen_time = "1660894030";
captcha_output = "fI9I34MDjVi10gJO_EqXwNpN8hK0rYLEPVWSDE4W6kc1umDoTHIlD_t6YQNNpPG2tJlKR8he6WFWkkllU8goGeNVNOzhqmAm256BpK8qAEHNrOjHzkNagfIcx_A21ssPrG6YlnnHFx3PfBnbrn5fb2aKDIi0I5xmCUjxq0dsFuANLIQVtllMjkJ7-1l_j-Wz";
captcha_id = "647f5ed2ed8acb4be36784e01556bb71";
lot_number = "0861c607d519469b9117d0c6dd551fe3";
}geelabCaptchaSession:didReceiveError:
Receives an error that occurs during the verification session.
Declaration
- (void)geelabCaptchaSession:(GeeLabCaptchaSession *)captchaSession
didReceiveError:(GeeLabCaptchaError *)error;Parameters
| Parameter | Description |
|---|---|
| captchaSession | The verification session. |
| error | The error description object. |
See Also
GeeLabCaptchaSession
The verification session.
delegate
The verification-session task delegate.
Declaration
@property (nonatomic, weak) id<GeeLabCaptchaSessionTaskDelegate> delegate;captchaID
The captcha ID of the current verification session.
Declaration
@property (nonnull, readonly, nonatomic, strong) NSString *captchaID;challenge
The transaction identifier of the current verification session.
Declaration
@property (nullable, readonly, nonatomic, strong) NSString *challenge;configuration
The configuration of the current verification session.
Declaration
@property (nonnull, readonly, nonatomic, strong) GeeLabCaptchaSessionConfiguration *configuration;sessionWithCaptchaID:
Creates a new verification-session instance.
Declaration
+ (instancetype)sessionWithCaptchaID:(NSString *)captchaID;Parameters
| Parameter | Description |
|---|---|
| captchaID | The captcha ID. |
Return Value
A new GeeLabCaptchaSession instance.
sessionWithCaptchaID:configuration:
Creates a new verification-session instance.
Declaration
+ (instancetype)sessionWithCaptchaID:(NSString *)captchaID
configuration:(nullable GeeLabCaptchaSessionConfiguration *)configuration;Parameters
| Parameter | Description |
|---|---|
| captchaID | The captcha ID. |
| configuration | The session configuration. |
Return Value
A new GeeLabCaptchaSession instance.
initWithCaptchaID:
Creates a new verification-session instance.
Declaration
- (instancetype)initWithCaptchaID:(NSString *)captchaID;Parameters
| Parameter | Description |
|---|---|
| captchaID | The captcha ID. |
Return Value
A new GeeLabCaptchaSession instance.
initWithCaptchaID:configuration:
Creates a new verification-session instance.
Declaration
- (instancetype)initWithCaptchaID:(NSString *)captchaID
configuration:(nullable GeeLabCaptchaSessionConfiguration *)configuration;Parameters
| Parameter | Description |
|---|---|
| captchaID | The captcha ID. |
| configuration | The session configuration. |
Return Value
A new GeeLabCaptchaSession instance.
verify
Starts verification.
Declaration
- (void)verify;cancel
Cancels verification.
Declaration
- (void)cancel;sdkVersion
Returns the SDK version.
Declaration
+ (NSString *)sdkVersion;GeeLabCaptchaSessionConfiguration
The verification-session configuration.
GeeLabCaptchaUserInterfaceStyle
The verification UI style.
Declaration
typedef NS_ENUM(NSInteger, GeeLabCaptchaUserInterfaceStyle) {
/** Follow the system appearance. */
GeeLabCaptchaUserInterfaceStyleSystem = 0,
/** Light appearance. */
GeeLabCaptchaUserInterfaceStyleLight,
/** Dark appearance. */
GeeLabCaptchaUserInterfaceStyleDark,
/** Default appearance. */
GeeLabCaptchaUserInterfaceStyleDefault = GeeLabCaptchaUserInterfaceStyleLight
};resourcePath
The full remote URL for static resources. The default is nil.
Declaration
@property (nullable, nonatomic, strong) NSString *resourcePath;protocol
The protocol for remote static resources. The default is @"https".
Declaration
@property (nonatomic, strong) NSString *protocol;userInterfaceStyle
The UI and status-bar style. The default is light.
Declaration
@property (nonatomic, assign) GeeLabCaptchaUserInterfaceStyle userInterfaceStyle;backgroundColor
The background color. The default is transparent.
Declaration
@property (nonatomic, strong) UIColor *backgroundColor;debugEnable
The debug-mode switch. Disabled by default.
Declaration
@property (nonatomic, assign) BOOL debugEnable;backgroundUserInteractionEnable
Controls interactions with the background. Enabled by default.
Declaration
@property (nonatomic, assign) BOOL backgroundUserInteractionEnable;timeout
The request timeout. The default is 8 seconds.
Declaration
@property (nonatomic, assign) NSTimeInterval timeout;language
The language. By default, it follows the system language. See the language-code documentation to specify a language.
Declaration
@property (nonatomic, strong) NSString *language;supportedInterfaceOrientations
The supported interface orientations.
Declaration
@property (assign, nonatomic) UIInterfaceOrientationMask supportedInterfaceOrientations;additionalParameter
Additional parameters. The default is nil. Parameters are assembled and submitted to the captcha service.
Declaration
@property (nullable, nonatomic, strong) NSDictionary *additionalParameter;Discussion
Supported key-value pairs are listed below.
| Key | Type | Description | Default value |
|---|---|---|---|
@"loading" | NSString | Custom loading indicator asset path relative to the HTML loaded by WebView. Set an empty string to disable loading. | @"./gt4-loading.gif" |
@"rem" | NSNumber | Overall captcha scale. | @(1) |
@"hideBar" | NSArray<NSString *> * | Hides the close and refresh buttons in subsequent verification screens. Use @[@"close", @"refresh"] to hide both. | @[] |
@"nextWidth" | NSString | Captcha dialog width, including units, such as @"300px". | nil |
@"riskType" | NSString | Specifies the verification type when used with risk-control integration. | nil |
@"hideSuccess" | NSNumber | Hides the verification-success dialog. @(0) / @(1) means visible / hidden. | @(0) |
Sample Code
#define captchaID @"1234567890abcdef"
GeeLabCaptchaSessionConfiguration *config = [GeeLabCaptchaSessionConfiguration defaultConfiguration];
NSMutableDictionary *params = [@{} mutableCopy];
[params setValue:@(1.25) forKey:@"rem"]; // Scale to 1.25x
[params setValue:@[@"close", @"refresh"] forKey:@"hideBar"]; // Hide close and refresh buttons
[params setValue:@"300px" forKey:@"nextWidth"];
[params setValue:@"click" forKey:@"riskType"]; // Must match the server configuration
[params setValue:@(1) forKey:@"hideSuccess"]; // Use NSNumber for Boolean values
[params setValue:@"./gt4-loading.gif" forKey:@"loading"];
config.additionalParameter = params;
GeeLabCaptchaSession *captchaSession = [GeeLabCaptchaSession sessionWithCaptchaID:captchaID configuration:config];
...defaultConfiguration
Returns the default configuration.
Declaration
+ (GeeLabCaptchaSessionConfiguration *)defaultConfiguration;Return Value
+ (GeeLabCaptchaSessionConfiguration *)defaultConfiguration {
GeeLabCaptchaSessionConfiguration *config = [[GeeLabCaptchaSessionConfiguration alloc] init];
config.debugEnable = NO;
config.timeout = 8.0;
config.language = [GeeLabCaptchaUtils systemLanguage];
config.protocol = @"https";
config.userInterfaceStyle = GeeLabCaptchaUserInterfaceStyleDefault;
config.backgroundColor = [UIColor clearColor];
config.backgroundUserInteractionEnable = YES;
return config;
}GeeLabCaptchaError
The error description object.
/// Invalid parameter. Check the supplied parameters.
FOUNDATION_EXPORT NSString * const GeeLabCaptchaErrorCodeInvalidParameter;
/// The operation failed. See the detailed description.
FOUNDATION_EXPORT NSString * const GeeLabCaptchaErrorCodeOperationFail;
/// A resource is missing. Verify that GeeLabCaptcha.bundle is complete.
FOUNDATION_EXPORT NSString * const GeeLabCaptchaErrorCodeMissedResource;
/// The user cancelled verification.
FOUNDATION_EXPORT NSString * const GeeLabCaptchaErrorCodeUserDidCancel;
/// Failed to load a file. Verify that the complete GeeLabCaptcha.bundle has been imported, or that configured remote static resources are accessible.
FOUNDATION_EXPORT NSString * const GeeLabCaptchaErrorCodeLoadFileFailure;
/// Loading timed out.
FOUNDATION_EXPORT NSString * const GeeLabCaptchaErrorCodeTimeout;
/// Failed to evaluate JavaScript.
FOUNDATION_EXPORT NSString * const GeeLabCaptchaErrorCodeEvaluatingJavascriptFail;
/// JavaScript returned an error.
FOUNDATION_EXPORT NSString * const GeeLabCaptchaErrorCodeJavascriptError;
/// WebView memory warning.
FOUNDATION_EXPORT NSString * const GeeLabCaptchaErrorCodeWebViewMemoryWarning;
/// Unknown error.
FOUNDATION_EXPORT NSString * const GeeLabCaptchaErrorCodeUnknown;code
The error code, which can be used for matching and handling errors.
Declaration
@property (readonly, nonatomic, strong) NSString *code;See Also
See the error-code list above.
msg
The error message, which can be displayed in the user interface.
Declaration
@property (readonly, nonatomic, strong) NSString *msg;desc
Detailed error information for troubleshooting.
Declaration
@property (readonly, nonatomic, strong) NSDictionary *desc;Discussion
Use this information to investigate operational issues encountered by users during verification.