Help Center > > SDK Reference> Using iOS SDK

Using iOS SDK

Updated at:Sep 02, 2020 GMT+08:00

Users can use SDK in token- or AK/SK-based authentication mode. For details about how to obtain authentication messages, see Authentication. This section describes how to use SDK in token- and AK/SK-based modes.

Download OCR Java SDK from, and decompress it.

A user needs to apply for enabling the service before using it for the first time. For details about how to enable the service, click Subscribe. You only need to subscribe to OCR once.

AK/SK-based Authentication

This section uses Passport OCR as an example to describe how to use SDK in AK/SK-based authentication mode.

  1. Obtain AK/SK. For details, see Authentication > AK/SK-based Authentication.
  2. Configure AK/SK of the iOS SDK.

    Change the values of AK and SK of the akskOcrService function in the ViewController.m file of the demo project to the obtained AK/SK.

    Figure 1 Modifying parameters in the ViewController.m file
  3. If you use a local image file for recognition, modify the image parameter in the akskOcrService function of the ViewController.m file. If you use the default image of the SDK, you do not need to modify the image path.
  4. Execute the akskOcrService function. If 200 is displayed on the console, the program is successfully executed. You can view the of Passport OCR on the console.
        "result": {
            "country_code": "IND", 
            "surname": "KUMAR", 
            "given_name": "ASHISH", 
            "passport_number": "G0080008", 
            "date_of_birth": "1988-08-18", 
            "sex": "M", 
            "date_of_expiry": "2017-11-25", 
            "machine_code": "P<INDKUMAR<<ASHISH<<<<<<<<<<<<<<<<<<<<<<<<<", 
            "machine_code2": "G0080008<2IND8808188M1711257<<<<<<<<<<<<<<<8", 
            "extra_info": {},
            "confidence": {
                "country_code": 0.9684, 
                "surname": 0.9684, 
                "given_name": 0.9684, 
                "passport_number": 0.9276, 
                "date_of_birth": 0.9276, 
                "sex": 0.9276, 
                "date_of_expiry": 0.9276, 
                "machine_code": 0.9684, 
                "machine_code2": 0.9276

    To call other OCR services, change the value of parameter uri of the akskOcrService function to the specific URI. For the URI list, see Mappings Between Services and APIs.

Token-based Authentication

This section uses Passport OCR as an example to describe how to use SDK in token-based authentication mode.

  1. Open the ViewController.m file. Change the values of username, password, and domainName in the tokenOcrService function to the actual username, password, and domain name registered with the system. If the user is not an IAM user, the domain name and username are the same.
    Figure 2 Changing the username, password, and domain name in the ViewController.m file
  2. Execute the code. The recognition result of Passport OCR is displayed.

Status Code

For details about status code, see Status Code.

Error Code

For details about error code, see Error Code.

Did you find this page helpful?

Submit successfully!

Thank you for your feedback. Your feedback helps make our documentation better.

Failed to submit the feedback. Please try again later.

Which of the following issues have you encountered?

Please complete at least one feedback item.

Content most length 200 character

Content is empty.

OK Cancel