All Products
Search
Document Center

ID Verification:iOS integration

Last Updated:Dec 04, 2025

The IDV NFC authentication service provides an iOS client software development kit (SDK). This SDK helps you add NFC authentication to your app. This topic describes the iOS client integration process and provides sample code.

Limits

  • The SDK is compatible with mobile devices (iPhone or iPad) that run iOS 13 or later.

  • The following privacy permissions are required: Camera (to use Optical Character Recognition (OCR) to obtain the three key elements of a passport), Network, and NFC.

Download and configure the SDK

Download the SDK

Download the iOS SDK, unzip the package, and then copy all frameworks to your project folder.

Add required permissions

  1. Add the following permissions to the Info.plist file. The permission descriptions are for reference only.

    image.png

  2. Add the Privacy - NFC Scan Usage Description permission and its description.

  3. Add the ISO7816 application identifiers for NFC Tag Reader Session configuration. Set item0 to A0000002471001 for travel documents.

    image.png

Add frameworks in Xcode

In your project settings, go to Build Settings > Build Phases > Link Binary With Libraries and add the frameworks.

  • Add all frameworks from the SDK:

    AliyunIdentityFace.framework
    AliyunIdentityPlatform.framework
    AliyunIdentityUtils.framework
    AliyunIdentityOcr.framework
    AliyunIdentityNFC.framework
    ToygerService.framework
    AliyunOSSiOS.framework
    faceguard.framework
    DTFUtility.framework
    ToygerNative.framework
    MNN.framework
    OpenSSL.framework
  • Add system dependency libraries:

    AudioToolbox.framework
    CoreMedia.framework
    CoreML.framework
    AVFoundation.framework
    SystemConfiguration.framework
    UIKit.framework
    CoreTelephony.framework
    CoreMotion.framework
    Accelerate.framework
    libresolv.tbd
    libsqlite3.tbd
    libc++.tbd
    libz.tbd
    
    CryptoKit.framework
    CryptoTokenKit.framework
    CoreNFC.framework
    libswiftCoreNFC.tbd

    Set the NFC-related system libraries to Optional. This prevents the app from crashing on devices that do not support NFC.

    image.png

Copy resource files

In your project settings, go to Build Settings > Build Phases > Copy Bundle Resources and copy the resource files.

  • AliyunIdentityPlatform.bundle: This resource is in AliyunIdentityPlatform.framework.

  • AliyunIdentityFace.bundle: This resource is in AliyunIdentityFace.framework.

  • AliyunIdentityOCR.bundle: This resource is in AliyunIdentityOcr.framework.

  • ToygerService.bundle: This resource is in ToygerService.framework.

  • AliyunIdentityNFC.bundle: This resource is in AliyunIdentityNFC.framework.

Configure Linker flags

In your project settings, go to Build Settings > Other Linker Flags and add the -ObjC flag.

For a pure Objective-C project, you must also add the -L$(DEVELOPER_DIR)/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/$(PLATFORM_NAME) flag.

Add a capability

In your project, select TARGETS, go to Signing & Capabilities, add a new capability, and then select NFC.

image.png

image.png

Call the SDK

Import the header file

#import <AliyunIdentityPlatform/AliyunIdentityPlatform.h>

Initialize the SDK

- (void)install;

Get metaInfo data

- (NSString *)getMetaInfo;

Call the SDK to start authentication

Important
  • Before you call the SDK to start authentication, make sure that you have passed the MetaInfo to the server and obtained the transactionId by calling the Initialize operation.

  • The transactionId returned by the server corresponds to the certifyId input parameter for this method.

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

    Name

    Type

    Description

    certifyId

    NSString

    Obtained by calling the server-side Initialize operation. Pass the returned transactionId to this parameter.

    viewController

    UIViewController

    The current ViewController of the client app.

    extParams

    NSDictionary

    Custom user parameters. In most cases, you can pass null.

    For a list of supported parameter fields, see extParams configuration.

    completeBlock

    AliyunIdentityVerifyBlock

    The callback after authentication is complete. It contains the authentication result. For more information about return codes, see the Return code table.

  • extParams configuration:

    Key

    Description

    Example (String)

    kIdentityParamKeyNextButtonColor

    The color of the button at the bottom of the OCR recognition result page.

    #FF0000

    kIdentityParamKeyRoundProgressColor

    The color of the circle during the face scan.

    #FF0000

    kIdentityParamKeyOcrSelectPhoto

    Specifies whether to display the album upload entry during document OCR recognition:

    • 1 (default): Display

    • 0: Do not display

    1

    kIdentityParamKeyMaxRetryCount

    The maximum number of retries. The value can be from 3 to 10. The default value is 10.

    10

    kIdentityParamKeyCardOcrTimeOutPeriod

    The timeout period for the OCR recognition step. The value can be from 20 to 60 seconds. The default value is 20 seconds.

    20

    kIdentityParamKeyFaceVerifyTimeOutPeriod

    The timeout period for the liveness collection and detection step. The value can be from 20 to 60 seconds. The default value is 20 seconds.

    20

    kIdentityParamKeyCardOcrEditTimeOutPeriod

    The duration for which the OCR recognition result page is editable. You can set a custom value from 60 to 180 seconds. By default, there is no limit.

    180

    kIdentityParamKeyLanguage

    You can customize the SDK language settings. By default, the SDK uses the mobile device's system language.

    Note

    For a list of languages supported by the SDK, see Custom languages for Android and iOS SDKs.

    zh-Hans

    kIdentityParamKeyDefaultLanguage

    The default language setting for the SDK. For possible values, see the kIdentityParamKeyLanguage field.

    The default value is en (English).

    en

    kIdentityParamKeyCloseButtonPosition

    The position of the SDK's Close button:

    • left (default): Left

    • right: Right

    left

    kIdentityParamKeyWatermark

    The watermark text after successful OCR recognition.

    Test watermark text

    kIdentutyParamKeyProtocol

    The SDK protocol.

    Note

    Obtain the protocol by calling the server-side Initialize operation and pass it in the extension parameters. This reduces internal SDK API interactions and improves network performance.

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

  • Return code table:

    Error code

    Billed

    Description

    1000

    Yes

    The user completed the face scan process, and the recommended authentication result is "pass". This result is for reference only. You can call the server-side CheckResult operation to get the final authentication result for further processing.

    1001

    Yes

    The user completed the face scan process, and the recommended authentication result is "fail". This result is for reference only. You can call the server-side CheckResult operation to get the final authentication result and the detailed reason for the failure for further processing.

    1002

    No

    A system error occurred.

    1003

    No

    The SDK failed to initialize. Check if the client's system time is correct.

    1004

    No

    A camera error occurred. Try the following steps to resolve the issue:

    1. Make sure the app has been granted camera permission before authentication.

    2. If the permission error persists after granting permission, try clearing the app cache and retry.

    1005

    No

    A network error occurred.

    1006

    No

    The user exited the process.

    1007

    No

    The TransactionId is invalid.

    1009

    No

    The client timestamp is incorrect.

    1011

    No

    The submitted document type is incorrect.

    1012

    No

    Key information from the recognized document is missing or failed format validation.

    1013

    No

    The image quality is poor.

    1014

    No

    The number of errors exceeded the upper limit.

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",
        kIdentutyParamKeyProtocol:@"968412EB......................."// Configure this protocol to optimize network latency.
    };
    // 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

Demo code package

You can download the iOS-NFCDemo for a demonstration.