This topic describes the APIs required to integrate the Captcha iOS software development kit (SDK).
Verification session task delegate protocol
Callback for verification session results
After you obtain the verification result, submit it to your business server to validate the parameters.
- (void)alicomCaptchaSession:(AlicomCaptcha4Session *)captchaSession
didReceive:(NSString *)status
result:(nullable NSDictionary *)result;Parameter | Description |
captchaSession | The verification session. |
status | The status code. If the value of status is @"1", the verification is complete. You must perform secondary validation on the result.
|
result | The parameters for result validation. |
Callback for errors in the verification session
(void)alicomCaptchaSession:(AlicomCaptcha4Session *)captchaSession
didReceiveError:(AlicomC4Error *)error;Parameter | Description |
captchaSession | The verification session. |
error | The error description object. |
Verification session
Verification session task delegate
@property (nonatomic, weak) id<AlicomCaptcha4SessionTaskDelegate> delegate;ID of the current verification session
@property (nonnull, readonly, nonatomic, strong) NSString *captchaID;Serial number of the current verification session
@property (nullable, readonly, nonatomic, strong) NSString *challenge;Verify the current session configuration
@property (nonnull, readonly, nonatomic, strong) AlicomCaptcha4SessionConfigurationCreate a verification session instance
+ (instancetype)sessionWithCaptchaID:(NSString *)captchaID;Parameter | Description |
captchaID | The verification ID. Enter the |
Configure a new verification session
+ (instancetype)sessionWithCaptchaID:(NSString *)captchaID
configuration:(nullable AlicomCaptcha4SessionConfigurationParameter | Description |
captchaID | The verification ID. Enter the |
configuration | The session configuration. |
Start verification |
|
Cancel verification |
|
Get the SDK version number |
|
Verification session configuration
Verification interface style
typedef NS_ENUM(NSInteger, AlicomC4UserInterfaceStyle) {
/** Follows the system style. */
AlicomC4UserInterfaceStyleSystem = 0,
/** Light style. */
AlicomC4UserInterfaceStyleLight,
/** Dark style. */
AlicomC4UserInterfaceStyleDark,
/** Default style. */
AlicomC4UserInterfaceStyleDefault = AlicomC4UserInterfaceStyleLight
}Path for remote access to static resources
The full path for remote access to static resources. The default value is empty.
@property (nullable, nonatomic, strong) NSString *resourcePath;Protocol for remote access to static resources
The protocol for remote access to static resources. The default value is @"https".
@property (nonatomic, strong) NSString *protocol;Interface style
The default interface theme is plain white.
@property (nonatomic, assign) AlicomC4UserInterfaceStyle userInterfaceSty;Background color
The background color. The default value is transparent.
@property (nonatomic, strong) UIColor *backgroundColor;Debug mode switch
The debug mode is disabled by default.
@property (nonatomic, assign) BOOL debugEnable;Background click interaction
The background click interaction is enabled by default.
@property (nonatomic, assign) BOOL backgroundUserInteractionEnable;Request timeout duration
The request timeout period. The default value is 8 seconds.
@property (nonatomic, assign) NSTimeInterval timeout;Set language
By default, the language of the Captcha interface follows the system language.
@property (nonatomic, strong) NSString *language;The supported languages and their language short codes are as follows:
Language | Language | Language short code |
Simplified Chinese | Chinese(Simplified) | zho |
Traditional Chinese (Hong Kong) | Chinese(Hong Kong) | zho-hk |
Traditional Chinese (Taiwan) | Chinese(Taiwan) | zho-tw |
American English | English | eng |
British English | English | eng-gb |
Japanese | Japanese | jpn |
Indonesia | Indonesian | ind |
Korean | Korean | kor |
Russian | Russian | rus |
Arabic | Arabic | ara |
Spanish | Spanish | spa |
French | French | fra |
German | German | deu |
Uyghur | Uyghur | udm |
Brazilian Portuguese | Portuguese(Brazil) | pon |
European Portuguese | Portuguese(Europe) | por |
Additional parameter settings
@property (nullable, nonatomic, strong) NSDictionary *additionalParameterThe supported key-value pairs are as follows:
Parameter | Type | Description | Default value |
|
| The relative path to a custom loading indicator resource. The WebView displays this resource while it loads the HTML. To hide the loading indicator, set this parameter to an empty string. |
|
|
| The overall scaling ratio for the Captcha. |
|
|
| Hides the Close and Refresh buttons on the validation interface. For example, set the value to |
|
|
| The width of the Captcha pop-up window. The value must include a unit, such as |
|
|
| Specifies whether to hide the success pop-up window after validation. A value of |
|
Get default configurations
+ (AlicomCaptcha4SessionConfiguration *)defaultConfiguration;Response example
+ (AlicomCaptcha4SessionConfiguration *)defaultConfiguration {
AlicomCaptcha4SessionConfiguration *config = [[AlicomCaptcha4SessionConfiguration alloc] init];
config.debugEnable = NO;
config.timeout = 8.0;
config.language = [AlicomC4Utils systemLanguage];
config.protocol = @"https";
config.userInterfaceStyle = AlicomC4UserInterfaceStyleDefault;
config.backgroundColor = [UIColor clearColor];
config.backgroundUserInteractionEnable = YES;
return config;
}Fault Description Object
/// Invalid parameter. Check the parameters that you entered.
FOUNDATION_EXPORT NSString * const AlicomC4ErrorCodeInvalidParameter;
/// The operation failed. For more information, see the description.
FOUNDATION_EXPORT NSString * const AlicomC4ErrorCodeOperationFail;
/// A resource is missing. Check whether the AlicomCaptcha4.bundle file is complete.
FOUNDATION_EXPORT NSString * const AlicomC4ErrorCodeMissedResource;
/// The user canceled the validation.
FOUNDATION_EXPORT NSString * const AlicomC4ErrorCodeUserDidCancel;
/// Failed to load the file. Check whether the complete AlicomCaptcha4.bundle file is imported or the configured remote static resources are accessible.
FOUNDATION_EXPORT NSString * const AlicomC4ErrorCodeLoadFileFailure;
/// Load timeout.
FOUNDATION_EXPORT NSString * const AlicomC4ErrorCodeTimeout;
/// Failed to execute the JavaScript script.
FOUNDATION_EXPORT NSString * const AlicomC4ErrorCodeEvaluatingJavascriptFail;
/// JavaScript returned an error.
FOUNDATION_EXPORT NSString * const AlicomC4ErrorCodeJavascriptError;
/// WebView memory warning.
FOUNDATION_EXPORT NSString * const AlicomC4ErrorCodeWebViewMemoryWarning;
/// An unknown error occurred.
FOUNDATION_EXPORT NSString * const AlicomC4ErrorCodeUnknown;code | Error code |
|
msg | Error message |
|
desc | Detailed error description |
|