iOS Integration Guide
The EngageLab Behavioral Verification iOS SDK is designed for developers integrating with iOS native client development. The SDK does not rely on any third-party libraries.
Product Overview
| Item | Description |
|---|---|
| Main Features | A new generation of CAPTCHA that intelligently addresses business losses and security risks caused by automated attacks from machine scripts. |
| SDK Privacy Policy | Policy |
| SDK Compliance Guide | Guide |
| SDK Download Link | (https://res.engagelab.net/docs/20251107/020242748/EngageLab-CAPTCHA-iOS-1.0.0.zip) |
Environment Requirements
| Item | Resource |
|---|---|
| Development Target | Compatible with iOS 9+ |
| Development Environment | Xcode 13.0+ |
| System Dependencies | Webkit.framework |
| SDK Third-party Dependencies | None |
Importing the SDK
If you are adding the SDK manually, drag the
GTCaptcha4.frameworkfile obtained from the download into your project, ensuring thatCopy items if neededis checked.Use the
Linked Frameworks and Librariesmethod to import the framework. After draggingGTCaptcha4.frameworkinto the project, ensure that the.frameworkfile is added toPROJECT -> Build Phases -> Linked Frameworks and Libraries.
The SDK provides an XCFramework format, located in the
SDK->XCFrameworkdirectory under the downloaded files asGTCaptcha4.xcframework.For
Categoryin static libraries, add-ObjCtoOther Linker FlagsunderBuild Settingsfor the corresponding target.
You also need to include
GT4Captcha4.Bundlein your project; otherwise, verification will not work. Drag theGTCaptcha4.Bundlefrom the SDK directory into your project.
At WWDC23, Apple announced new privacy policies for applications (including SDKs), with a dedicated session Get started with privacy manifests - WWDC23 - Videos - Apple Developer. On July 27, Apple released a news update stating that starting in Fall 2023, if newly uploaded applications use related APIs without providing a privacy manifest, you will receive an email notification. Starting in Spring 2024, privacy manifests will become mandatory. For the APIs involved and usage reasons, refer to: Describing use of required reason API | Apple Developer Documentation. If the usage reason is not listed, you can directly submit a specific usage explanation.
To create a new privacy manifest, refer to Privacy manifest files | Apple Developer Documentation.
The Behavioral Verification iOS SDK uses some functions to obtain disk capacity and environment detection information for risk control purposes, involving the categories NSPrivacyAccessedAPICategoryDiskSpace and NSPrivacyAccessedAPICategoryFileTimestamp. This is hereby stated.
Configuration Interface
Refer to the Product Structure Process of Behavioral Verification. You must first set up the corresponding server-side interface on your backend and configure the
captchaIdandKeyobtained from the EngageLab Management Console.
Developers integrating the SDK need to use the following interfaces provided by the iOS SDK:
- Configure verification initialization using the ID.
- Start verification.
- Obtain verification result parameters and perform secondary validation on the submitted result parameters to prevent forgery.
- Handle potential issues during verification using error delegate methods.
You need to adhere to the <GTCaptcha4SessionTaskDelegate> protocol to handle verification results and possible errors.
Refer to the Code Examples below for integration code.
Compile and Run Your Project
Compile your project and experience behavioral verification.

Code Examples
Initialization and Verification Call
Import the header file of the verification dynamic library GTCaptcha4.framework in your project.
#import <GTCaptcha4/GTCaptcha4.h>
Take integration within a
UIButtonas an example.
Initialization
Initialize an instance of the verification manager
GTCaptcha4Session. In theUIButtoninitialization method, call the registration method of theGTCaptcha4Sessioninstance to obtain registration data:#define captchaID @"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" @interface ViewController () <GTCaptcha4SessionTaskDelegate> @property (strong, nonatomic) IBOutlet UIButton *startBtn; @property (nonatomic, strong) GTCaptcha4Session *captchaSession; @end @implementation ViewController - (GTCaptcha4Session *)captchaSession { if (!_captchaSession) { /// Create instance GTCaptcha4SessionConfiguration *config = [GTCaptcha4SessionConfiguration defaultConfiguration]; // config.timeout = 8.0f; /// Set intermediate page address, must be set as per the example config.resourcePath = @"https://captcha-stat.engagelab.com/www/gt4-index.html"; /// Set apiServer and staticServer, must be set as per the example config.apiServers = @[@"captcha-api.engagelab.com"]; config.staticServers = @[@"captcha-stat.engagelab.com/www/js"]; /// Request protocol config.protocol = @"https"; _captchaSession = [GTCaptcha4Session sessionWithCaptchaID:captchaID configuration:config]; _captchaSession.delegate = self; } return _captchaSession; } - (void)viewDidLoad { [super viewDidLoad]; // Pre-initialize the verification session. If not called here, lazy loading will be used. [self captchaSession]; [self.startBtn addTarget:self action:@selector(start) forControlEvents:UIControlEventTouchUpInside]; }#define captchaID @"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" @interface ViewController () <GTCaptcha4SessionTaskDelegate> @property (strong, nonatomic) IBOutlet UIButton *startBtn; @property (nonatomic, strong) GTCaptcha4Session *captchaSession; @end @implementation ViewController - (GTCaptcha4Session *)captchaSession { if (!_captchaSession) { /// Create instance GTCaptcha4SessionConfiguration *config = [GTCaptcha4SessionConfiguration defaultConfiguration]; // config.timeout = 8.0f; /// Set intermediate page address, must be set as per the example config.resourcePath = @"https://captcha-stat.engagelab.com/www/gt4-index.html"; /// Set apiServer and staticServer, must be set as per the example config.apiServers = @[@"captcha-api.engagelab.com"]; config.staticServers = @[@"captcha-stat.engagelab.com/www/js"]; /// Request protocol config.protocol = @"https"; _captchaSession = [GTCaptcha4Session sessionWithCaptchaID:captchaID configuration:config]; _captchaSession.delegate = self; } return _captchaSession; } - (void)viewDidLoad { [super viewDidLoad]; // Pre-initialize the verification session. If not called here, lazy loading will be used. [self captchaSession]; [self.startBtn addTarget:self action:@selector(start) forControlEvents:UIControlEventTouchUpInside]; }This code block in the floating windowFor other optional configuration items, see the interfaces or properties defined in
GTCaptcha4SessionConfiguration.Call Verification
After initialization, call the following method to perform verification:
- (void)start { [self.captchaSession verify]; }- (void)start { [self.captchaSession verify]; }This code block in the floating window
Handling Verification Results
Verification is only complete after validating the verification results. You need to handle the following delegate methods after adhering to the GTCaptcha4SessionTaskDelegate protocol:
- (void)gtCaptchaSession:(GTCaptcha4Session *)captchaSession didReceive:(NSString *)code result:(NSDictionary *)result {
NSLog(@"result: %@", result);
// code is @"1" if the user completed the verification, @"0" if the user failed verification
if ([@"1" isEqualToString:code]) {
if (result && result.count > 0) {
// Convert dictionary to form format for submission (construct based on actual interface data format requirements)
__block NSMutableArray<NSString *> *kvPairs = [NSMutableArray array];
[result enumerateKeysAndObjectsUsingBlock:^(id _Nonnull key, id _Nonnull obj, BOOL * _Nonnull stop) {
if ([key isKindOfClass:[NSString class]] &&
[obj isKindOfClass:[NSString class]]) {
NSString *kvPair = [NSString stringWithFormat:@"%@=%@", key, obj];
[kvPairs addObject:kvPair];
}
}];
NSString *formStr = [kvPairs componentsJoinedByString:@"&"];
NSData *data = [formStr dataUsingEncoding:NSUTF8StringEncoding];
// Backend verification interface provided by the business, must be set as per the example
NSURL *url = [NSURL URLWithString:@"https://captcha-api.engagelab.com/validate"];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
request.HTTPMethod = @"POST";
request.HTTPBody = data;
// Submit to the backend for result validation
[[[NSURLSession sharedSession] dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
if (!error && data) {
// Handle verification results
NSString *msg = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSLog(@"result: %@", msg);
}
else {
NSLog(@"error: %@", error);
}
}] resume];
}
}
}
Handling Verification Errors
Unexpected errors may occur during verification. You can handle them in the following delegate method after adhering to the GTCaptcha4SessionTaskDelegate protocol:
- (void)gtCaptchaSession:(GTCaptcha4Session *)captchaSession didReceiveError:(GTC4Error *)error {
// Display error information and error code to the user
// Log error details
NSLog(@"error: %@", error.description);
}
It is strongly recommended to display both the error reason and error code to the user when showing verification errors, to facilitate troubleshooting of online issues.
Swift Example
For more detailed example code, refer to the official Demo provided. For Swift example code, refer to the DefaultDemoViewController.swift file in the Demo source code.









