tencent cloud

eKYC

iOS Interface Overview

Download
Focus Mode
Font Size
Last updated: 2026-10-27 14:31:48
AI-Translated & Reviewed
The main classes involved in the iOS OCR SDK include OcrOverseasCloudKit, OcrCloudConfig, OcrCloudResult, OcrCloudError, and CustomConfigUI. The APIs supported by these classes are described in detail below.


OcrOverseasCloudKit

OcrOverseasCloudKit is the public entry class of the SDK. It uses Token mode and centralizes all OCR features.
API
Capability Description
Obtaining the OcrOverseasCloudKit Singleton
Releasing SDK Resources
Obtaining the SDK Version Number
Initializing the SDK
Obtaining SDK Metadata
Starting Token Mode Recognition

sharedInstance()

+ (nonnull instancetype)sharedInstance;
Description: Obtain the singleton instance of OcrOverseasCloudKit.
Return value: The OcrOverseasCloudKit singleton instance.


clearInstance()

- (void)clearInstance;
Description: Actively releases SDK resources. Call this method when exiting the app or when cleanup is required.


getVersion()

- (NSString *)getVersion;
Description: Obtains the current SDK version string.
Return value: The version string, for example, "4.0.2".


initWithViewController()

- (void)initWithViewController:(UIViewController *)viewController;
Description: Initializes the SDK by passing in the ViewController that hosts the recognition page.
Input parameters:
Parameter Type
Parameter Name
Parameter Description
UIViewController
viewController
ViewController that hosts the recognition page


createMetaData()

+ (NSString *)createMetaData;
Description: Obtains the device metadata string, which is passed as an input parameter when applying for the sdkToken.
Return value: The metadata JSON string (Base64-encoded).


startCloudOcr:withSucceedBlock:withFailedBlock:

- (void)startCloudOcr:(OcrCloudConfig *_Nonnull)cloudConfig
withSucceedBlock:(OcrCloudSucceedBlock _Nonnull)onSucceed
withFailedBlock:(OcrCloudFailedBlock _Nonnull)onFailed;
Description: Starts OCR recognition in Token mode. After the SDK completes data collection, it returns the sdkToken through a success callback. The host App then uses this Token to pull the final recognition result from the server.
Input parameters:
Parameter Type
Parameter Name
Parameter Description
cloudConfig
Token mode configuration object
OcrCloudSucceedBlock
onSucceed
Callback for successful capture, returning OcrCloudResult
OcrCloudFailedBlock
onFailed
Callback for recognition failure, returning OcrCloudError


OcrCloudConfig

OcrCloudConfig is the configuration object passed in when the SDK is started in Token mode.
Type
Term
Description
Required
NSString
sdkToken
Business Token, obtained by the host App from the server, used to connect the entire recognition process.
Required
NSString
serverParamInfo
Server parameter information
Required
customConfigUI
Custom UI configuration
No


OcrCloudResult

OcrCloudResult is the result object returned by the success callback in Token mode.
Type
Term
Description
NSString
sdkToken
Business Token used by the host App to pull final recognition results from the server.


OcrCloudError

OcrCloudError is the error object returned by the failure callback in Token mode.
Type
Term
Description
NSString
sdkToken
Business Token (used for issue locating)
NSInteger
errorCode
Error code. For details, see Error code.
NSString
errorMsg
Error message description


OcrOverseasCustomConfigUI

OcrOverseasCustomConfigUI is an optional UI configuration class passed in when the SDK is started.
Type
Term
Description
Default Value
id<OcrOverseasViewDelegate>
delegate
UI-related delegate
nil
landscapeMode
Landscape mode configuration
OcrLandscapeModePortrait
BOOL
isShowTips
Display intermediate prompt or not
YES
NSString
tipsShowText
Intermediate prompt content (up to 15 Chinese characters)
Avoid folded corners, obstructions, and poor lighting on the content to be recognized.
UIImage
takePictureImage
Capture button icon, 80×80
Default icon
UIImage
lightONImage
Flashlight on button icon, 40×40
Default icon
UIImage
lightOFFImage
Flashlight off button icon, 40×40
Default icon
UIImage
albumImage
Album button icon, 40×40
Default icon
BOOL
isShowLight
Display flashlight button or not
YES
languageType
Set current language.
OCR_DEFAULT
BOOL
openClipImage
Enable album image cropping page.
YES
BOOL
supportOnlyAlbumMode
Support album-only mode when camera permission is unavailable.
NO
BOOL
isShowPrivacyAgreementDialog
Display privacy agreement dialog or not
YES
BOOL
isForbidAnima
Hide OCR transition animation for opening/exiting.
YES
CGFloat
cardFrameWidth
Width of the four corner borders of the recognition frame
2.0
BOOL
showBestImgConfirmDialog
Best frame confirmation dialog (OCR_DETECT_AUTO mode only)
NO
NSArray<UIColor *>
custRectColorArr
Recognition frame color array [normal, error, pass]
nil
NSArray<UIColor *>
custTipsColorArr
Tip color array [normal, error, pass]
nil
UIFont
custTipsFont
Custom tip font
nil
NSString
ocrSDKBundlePath
OcrSDK.bundle file path, read from the main bundle by default
nil
NSString
ocrModelPath
OcrModel.bundle file path, read from the main bundle by default.
nil
NSString
custBundlePath
Custom UI bundle path
nil
NSString
custLanguageBundlePath
Custom multilingual bundle path
nil
NSString
custLanguageFile
Custom language file name (such as en.lproj)
nil
CGFloat
custRectScaleY
Y-axis offset percentage of the recognition frame, effective only in portrait mode.
0.21
CGFloat
custRectScaleX
X-axis offset percentage of the recognition frame
0.01


OcrLandscapeMode

The OcrLandscapeMode enum lists the supported landscape modes:
Type
Description
Scenario
OcrLandscapeModePortrait
Portrait (default)
Recognition in portrait scenarios
OcrLandscapeModeUIRotateLandscapeLeft
UI rotated landscape - front camera on the left
The project supports only portrait mode, and landscape is achieved by rotating the page.
OcrLandscapeModeUIRotateLandscapeRight
UI rotated landscape - front camera on the right
The project supports only portrait mode, and landscape is achieved by rotating the page.
OcrLandscapeModeDeviceLandscapeLeft
Device rotated landscape - front camera on the left
The project supports landscape mode, and the device has a fixed rotation direction.
OcrLandscapeModeDeviceLandscapeRight
Device rotated landscape - front camera on the right
The project supports landscape mode, and the device has a fixed rotation direction.


OcrLanguageType

The OcrLanguageType enum lists the language settings:
Type
Description
OCR_DEFAULT
Follow system
OCR_ZH_HANS
Simplified Chinese
OCR_ZH_HANT
Traditional Chinese
OCR_EN
English
OCR_CUSTOMIZE_LANGUAGE
Custom language
OCR_INDONESIA
Indonesian


Error Codes

OcrCloudError.errorCode error code description:
Error Code
Description
100100
Parameter exception
100102
Network exception.
100103
Camera permission exception.
101000
Recognition failed.
200101
The user actively cancels the recognition.
300101
Model initialization failed.
300102
Server response parsing exception.
300103
API signature failed.
300104
Camera exception.
300105
SDK initialization configuration failed.
300106
Image data is empty.
300107
Authorization failed.
300108
System version is too low (lower than iOS 11.0).
300109
Automatic mode timeout.
300110
SDK internal error.
300112
Document type mismatch.
300113
Excessive consecutive recognition failures.
300114
Video recording failed.
300115
The application was switched during the recognition process.
400100
Alarm Code for triggering specified interception.
400101
The document type provided by the user does not match the specified document type.
400102
The document side provided by the user does not match the selected side.
400103
The document occupies too small a proportion of the photo provided by the user.
400104
The photo provided by the user contains multiple document photos.
400105
OCR recognition failure.
400106
Document information verification failure.
400107
Input parameter error.
400108
Internal service error.
400109
Service not activated / Account overdue payment / Resource bundle exhausted / Billing exception.
400110
Rate limiting triggered.
400111
File size too large or invalid.
400112
File parsing failure.


Recognition Result Callback

The callback definitions for Token mode are as follows:
/// Success callback for Token mode
/// @param result The success result, which contains the sdkToken.
typedef void (^OcrCloudSucceedBlock)(OcrCloudResult *_Nonnull result);

/// Failure callback for Token mode
/// @param error The failure information, which contains the sdkToken, errorCode, and errorMsg.
typedef void (^OcrCloudFailedBlock)(OcrCloudError *_Nonnull error);
Note:
After the success callback is triggered, the SDK returns only the sdkToken. The final recognition result must be pulled by the host App server from Tencent Cloud OCR using the sdkToken.
If the user actively cancels recognition, the failure callback is triggered, and the errorCode is 200101.
For API responses, refer to the official documentation. For error code descriptions, refer to Error Codes.


Help and Support

Was this page helpful?

Help us improve! Rate your documentation experience in 5 mins.

Feedback