All Products
Search
Document Center

ID Verification:Integrate the iOS SDK via SPM

Last Updated:Jul 09, 2026

Integrate the ID Verification SDK into your iOS app using Swift Package Manager (SPM) to enable eKYC remote identity verification.

Requirements

  • iOS 12 or later (iPhone or iPad).

  • Privacy permissions: camera, network.

Download and configure the SDK

Download the SDK

Download the SDK from Client SDK release notes, extract the package, and import it through SPM.

Add required permissions

Add the following permissions to your Info.plist file. The description strings are examples only.

image

Import the package

  1. Add the package.image

  2. Import it locally.image

  3. Confirm the addition.image

  4. Resulting directory structure:image

Invoke the SDK

Import the header file

#import <AliyunIdentityPlatform/AliyunIdentityPlatform.h>

Initialize the SDK

- (void)install;
- (void)installWithOptions:(NSMutableDictionary *)options;

Parameters:

The options parameter, which is null by default, specifies optional data collection settings.

Important
  • The ID Verification client includes a built-in security module known as the device helper. The device helper provides various data reporting regions to meet local data collection compliance requirements. You can set CustomUrl and CustomHost to specify different reporting sites based on user attributes.

  • Only one data reporting region can be specified per application session lifecycle. The region for server-side queries must match the reporting region. The supported regions vary by product. For more information, see Supported regions.

  • For each region, the CustomUrl is as follows:

    • China (Hong Kong): https://cloudauth-device.cn-hongkong.aliyuncs.com

    • Singapore: https://cloudauth-device.ap-southeast-1.aliyuncs.com

    • Indonesia (Jakarta): https://cloudauth-device.ap-southeast-5.aliyuncs.com

    • US (Silicon Valley): https://cloudauth-device.us-west-1.aliyuncs.com

    • Germany (Frankfurt): https://cloudauth-device.eu-central-1.aliyuncs.com

    • Malaysia (Kuala Lumpur): https://cloudauth-device.ap-southeast-3.aliyuncs.com

Parameter

Description

Example

IPv6

Indicates whether to use an IPv6 domain name to report device information:

  • 0 (default): No (uses an IPv4 domain name)

  • 1: Yes (uses an IPv6 domain name)

"1"

DataSwitch

Controls when to report device information:

  • 0 (default): When the SDK initializes

  • 1: When you obtain a token

Note

The default setting is recommended.

"1"

CustomUrl

Sets the server domain name for data reporting.

See CustomUrl for each region.

CustomHost

Sets the server host for data reporting.

"cloudauth-device.ap-southeast-1.aliyuncs.com"

Note

This example is for the Singapore region. For server hosts in other regions, see CustomUrl for each region.

Retrieve metaInfo

- (NSString *)getMetaInfo;

Your server uses metaInfo to initialize a session with Alibaba Cloud and obtain a transactionId for verification.

Call getMetaInfo, send the result to your server, and use the returned transactionId to start verification.

Start verification

- (void)verifyWithCertifyId:(NSString *)certifyId
  withCurrentViewController:(UIViewController *)viewController
              withExtParams:(NSDictionary *)extParams
                   complete:(AliyunIdentityVerifyBlock)completeBlock;

Parameters

Name

Type

Description

transactionId

NSString

Returned by the server-side Initialize API.

viewController

UIViewController

The current ViewController.

extParams

NSDictionary

Custom parameters. Pass null if not required.

For currently supported fields, see extParams Configuration.

completeBlock

AliyunIdentityVerifyBlock

Callback with the verification result.

extParams Configuration

Key

Description

Example (string)

kIdentityParamKeyNextButtonColor

Color of the bottom button on the OCR recognition result page.

#FF0000

kIdentityParamKeyRoundProgressColor

Color of the circular progress indicator during the face scan.

#FF0000

kIdentityParamKeyOcrSelectPhoto

Whether to show the photo album upload option during ID OCR recognition:

  • 1 (default): Show

  • 0: Do not show

1

kIdentityParamKeyShowOcrResult

Whether to show the recognition result page after ID OCR recognition:

  • 1 (default): Show

  • 0: Do not show

1

kIdentityParamKeyEditOcrResult

Whether the recognition result page is editable during ID OCR recognition:

  • 1 (default): Editable

  • 0: Not editable

1

kIdentityParamKeyMaxRetryCount

Maximum number of retries. Valid values: 3 to 10. Default value: 10.

10

kIdentityParamKeyCardOcrTimeOutPeriod

Timeout for OCR recognition, in seconds. Valid values: 20 to 60. Default value: 20.

20

kIdentityParamKeyFaceVerifyTimeOutPeriod

Timeout for liveness detection, in seconds. Valid values: 20 to 60. Default value: 20.

20

kIdentityParamKeyCardOcrEditTimeOutPeriod

Duration (in seconds) that the OCR recognition result page remains editable. Valid values: 60 to 180. By default, the duration is unlimited.

180

kIdentityParamKeyLanguage

SDK display language. By default, the SDK uses the system language.

Note

For a list of supported languages, see Customize languages for the Android and iOS SDKs.

zh-Hans

kIdentityParamKeyDefaultLanguage

Default SDK language. For valid values, refer to kIdentityParamKeyLanguage.

The default value is en (English).

en

kIdentityParamKeyCloseButtonPosition

Position of the close button in the SDK UI:

  • left (default)

  • right

left

kIdentityParamKeyWatermark

Watermark text displayed after successful OCR recognition.

Test watermark text

kIdentityParamKeyProtocol

Pre-fetched SDK protocol content.

Note

Obtain the protocol from the server-side Initialize API and pass it here to reduce internal SDK API calls and improve startup performance.

968412EB*******...

Error codes

Error code

Billing status

Subcode

Description

1000

Yes

A1000_1

The user completed face verification with a suggested result of "Pass". This is for reference only. Call the server-side CheckResult API for the final result.

1001

Yes

A1001_1

The user completed face verification with a suggested result of "Fail". This is for reference only. Call the server-side CheckResult API for the final result and failure reason.

1002

No

A1002_1

The machine learning model failed to load.

A1002_3

Failed to load the module.

A1002_4

iOS version is earlier than 9.0.

A1002_5

Network interface error.

1003

No

A1003_1

Initialize API call failed: empty response content.

A1003_2

Initialize API call failed: invalid content format.

A1003_3

Failed to parse the client-side initialization protocol.

A1003_4

Initialize API call failed: content decryption error.

A1003_5

Initialize API call failed.

A1003_6

Initialize API call failed: empty OSS field in response.

A1003_7

The context is empty.

1004

No

A1004_1

Front-facing camera error.

A1004_2

Failed to open the camera.

A1004_3

User denied camera permission.

1005

No

A1005_1

Network error during the Initialize API call.

A1005_2

Network error during the authentication API call.

1006

No

A1006_1

User canceled the process.

A1006_2

Process timed out after 15 minutes of inactivity.

1007

No

A1007_1

Invalid authentication ID.

1014

No

A1014_1

Maximum retries exceeded.

1017

No

A1017_1

Invalid product code.

Sample code

#import "ViewController.h"
#import <AliyunIdentityPlatform/AliyunIdentityPlatform.h>

@interface ViewController ()
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
 
    // Initialize the sdk
    [[AliyunIdentityPlatform sharedInstance] install];
 
    [self initUI];
}

// This function needs to be implemented by the user
- (NSString *)sentMetaInfoAndGetTransactionId:(NSString*) metaInfo {
    return @"Get TransactionId from your server."; // replace it.
}

- (void)onClickStart:(id) sender {
    NSString *metaInfo = [[AliyunIdentityPlatform sharedInstance] getMetaInfo];
    NSString *transactionId = [self sentMetaInfoAndGetTransactionId:metaInfo];

    // Set the sdk language
    NSDictionary *extParams = @{
        kIdentityParamKeyLanguage:@"en",
        kIdentityParamKeyProtocol:@"968412EB......................."// Configure this protocol to optimize network latency. Obtain it from the server-side initialization API.
    };
    // start Verify
    [[AliyunIdentityPlatform sharedInstance] verifyWithCertifyId:transactionId
                                       withCurrentViewController:self
                                                   withExtParams:extParams
                                                        complete:^(AliyunIdentityVerifyRes *response) {
        NSString *resContent = [NSString stringWithFormat:@"Code=%d Message=%@", response.code, response.message];
    }];
}

- (void)initUI {
    // ......
}

@end

SDK components

Clippable

Module

Module Description

Incremental Package

Clippable

AliyunIdentityNFC

NFC unavailable after removal.

3.7M

Clippable

OpenSSL

NFC unavailable after removal.

Clippable

AliyunIdentityOcr

OCR and eKYC authentication are unavailable after removal.

0.8M

Clippable

faceguard

Secures the client-side environment during face recognition. Removal weakens security.

0.74M

Clippable

AliyunIdentityFace

Facial liveness detection unavailable after removal.

2.2M

Not Clippable

AliyunIdentityPlatform

Not Clippable

0.04M

Not Clippable

AliyunIdentityUtils

Not Clippable

0.04M

Clippable

IDVMNN

Far/near liveness detection, facial quality, and OCR auto-scan are unavailable after removal.

0.09M

Not Clippable

AliyunOSSiOS

Not Clippable

0.23M