Onfido logo home page
Watch a demo
Get in touch
Arrow back Back to guides

NFC for Document report

Start here

Recent passports, identity cards and residence permits contain a chip which can be accessed using Near Field Communication (NFC). In this case, Onfido can use NFC to validate the document during a check containing a Document report.

Follow this guide to:

  • set up your integration for NFC
  • create a check composed of a Document report with NFC

You can view the list of currently supported documents for NFC.

Please contact your Customer Success manager for additional help integrating with NFC.

Enable NFC in the Onfido SDKs

NFC is only available via the Onfido iOS and Android mobile SDKs. The SDKs provide a set of screens to extract the information contained in the chip via NFC to verify the original document is present.

You must enable NFC in your app and the SDK in order to complete a Document report with NFC.

App build

iOS

  • Add Near Field Communication Tag Reading capability in your app target. You can follow the steps in Apple's documentation
  • Include the following entries in your app target's Info.plist file
<key>com.apple.developer.nfc.readersession.felica.systemcodes</key>
<array>
  <string>12FC</string>
</array>
<key>com.apple.developer.nfc.readersession.iso7816.select-identifiers</key>
<array>
  <string>A0000002471001</string>
  <string>A0000002472001</string>
  <string>00000000000000</string>
  <string>D2760000850101</string>
</array>

Android

NFC dependencies are not included in the SDK to avoid increasing the SDK size when the NFC feature is disabled. To use the NFC feature, you need to include the following dependencies (with the specified versions) in your build script:

implementation "net.sf.scuba:scuba-sc-android:0.0.23"
implementation "org.jmrtd:jmrtd:0.7.32"

You also need to add the following Proguard rules to your proguard-rules.pro file:

-keep class org.jmrtd.** { *; }
-keep class net.sf.scuba.** {*;}
-keep class org.bouncycastle.** {*;}
-keep class org.ejbca.** {*;}

-dontwarn kotlin.time.jdk8.DurationConversionsJDK8Kt
-dontwarn org.ejbca.**
-dontwarn org.bouncycastle.**
-dontwarn module-info
-dontwarn org.jmrtd.**
-dontwarn net.sf.scuba.**

React Native

All configurations described above for iOS and Android are needed for React Native App


Configure the SDK

iOS

Pass the following method to invoke NFC in the iOS SDK.

let config = try! OnfidoConfig.builder()
    .withSDKToken("<YOUR_SDK_TOKEN_HERE>")
    .withDocumentStep()
    .withNFCReadBetaFeatureEnabled()
    .build()
ONFlowConfigBuilder *configBuilder = [ONFlowConfig builder];

[configBuilder withSdkToken:@"YOUR_SDK_TOKEN_HERE"];
[configBuilder withDocumentStep];
[configBuilder withPassportNFCReadBetaFeatureEnabled];

NSError *configError = NULL;
ONFlowConfig *config = [configBuilder buildAndReturnError:&configError];

Android

Pass the following method to add the NFC document extraction step to the Android SDK flow. The step will be shown when NFC extraction is supported for the document selected by the user.

val config = OnfidoConfig.builder(this@MainActivity)
   .withSDKToken(<YOUR_SDK_TOKEN_HERE>)
   .withNFCReadBetaFeature()
   .withCustomFlow(flowSteps)
   .build()
OnfidoConfig config = OnfidoConfig.builder(context)
    .withSDKToken(<YOUR_SDK_TOKEN_HERE>)
    .withNFCReadBetaFeature()
    .withCustomFlow(flowSteps)
    .build()

React Native

config = {
  sdkToken:EXAMPLE-TOKEN-123,
  flowSteps: {
    welcome: true,
    captureDocument: {
      docType: OnfidoDocumentType.DRIVING_LICENSE,
      countryCode: OnfidoCountryCode.USA
    },
    captureFace: {
      type: OnfidoCaptureType.VIDEO
    },
  },
  enableNFC: true
}

Upgrade to API v3.2

You must upgrade your backend to use API v3.2 onwards in order to consume the NFC breakdown and sub-breakdowns in the Document report.

NFC is not available in earlier versions of the Onfido API. Please refer to our API versioning policy.

Create a check containing a Document report with NFC

Once you have enabled NFC in the Onfido SDK and upgraded to API v3.2 onwards, you can create a check containing a Document report with NFC.

Start the SDK flow

The SDK flow for a Document report with NFC includes both the standard document step capture screens and additional NFC scan screens.

All users will first be presented with the document capture screens. The additional NFC screens will then be presented to the user if both the user's device and the document type support NFC. Otherwise, the user will finish the SDK flow after the document capture step and no NFC scan will be completed.

Document IDs

On success the SDK will return a callback which contains an array of document IDs. The document IDs will include:

  • the document front image
  • the document back image (if the document has 2 sides, for example an ID card)
  • the NFC media (if the document is supported for NFC and an NFC scan has completed successfully)

You need to extract all the document IDs to use when creating a check on the backend.

iOS
func getDocumentIds(fromResults results: [OnfidoResult]) -> [String]? {
        return results.map({ onfidoResult -> [String] in
            switch onfidoResult {
            case .document(let documentResult):
                guard let nfcMediaId = documentResult.nfcMediaId else {
                    return []
                }
                var ids: [String] = [documentResult.front.id]
                if let backId = documentResult.back?.id {
                    ids.append(backId)
                }
                ids.append(nfcMediaId)
                return ids
            default:
                return []
            }
        }).first
    }

OnfidoFlow(...)
    .with(responseHandler: { response in
        switch response {
            case .success(let results):
                if let documentIds = getDocumentIds(fromResults: results) {
                   // USE DOCUMENT IDS FOR CHECK CREATION
                }
            ...
        }
    })
Android
override fun userCompleted(captures: Captures) {
    val documentIds = captures.toJson()
    // add the document ids to check creation request body
    add("document_ids", documentIds)
}

private fun Captures.toJson(): JsonArray {
    val array = JsonArray()
    document?.nfcMediaUUID?.let { uuid -> array.add(uuid) }
    document?.front?.let { frontSide -> array.add(frontSide.id) }
    document?.back?.let { backSide -> array.add(backSide.id) }
    return array
}
React Native
Onfido.start({
      sdkToken: 'sdkTokenFromOnfidoServer',
      flowSteps: {
        welcome: true,
        captureFace: {
          type: OnfidoCaptureType.VIDEO,
        },
        captureDocument: {
          docType: OnfidoDocumentType.DRIVING_LICENCE,
          countryCode: OnfidoCountryCode.USA,
        },
        enableNFC: true,
      },
    })
      .then(res =>
        const result = JSON.stringify(res);
        const nfcMediaId = result.document.nfcMediaId ?? result.document.nfcMediaUUID;
        const frontId = result.document.front.id;
        const backId = result.document.back.id;

      )
      .catch(err => console.warn('OnfidoSDK: Error:', err.code, err.message));
  }

Create a check

On success, create a check on your backend.

Example for an NFC supported passport:

curl -X POST https://api.eu.onfido.com/v3.2/checks \
  -H 'Authorization: Token token=<YOUR_API_TOKEN>' \
  -H 'Content-Type: application/json' \
  -d '{
  "applicant_id": "<APPLICANT_ID>",
  "report_names": ["document"],
  "document_ids": ["<DOCUMENT_ID_FRONT>", "<NFC_MEDIA_ID>"]
}'
Parameter Notes
applicant_id (required) Specifies the applicant for the check.
report_names (required) The report name. NFC is available as part of the primary Document report option.
document_ids (required) Array including all the document IDs returned in the SDK success callback. This could include up to 3 IDs for the document front side, back side and NFC media.

Note: document_ids is only a required parameter for a Document report with NFC as you need to specify the NFC media ID at check creation. For a standard Document report, document_ids is an optional parameter.

For more details on how to create a check, see our quick start guide for iOS, Android SDKs.

Result handling

Report breakdown

The issuing authority breakdown captures the result of the NFC scan. It asserts whether data on the document matches the issuing authority data and uses the following sub-breakdowns:

  • nfc_passive_authentication - asserts the data integrity of the NFC data
  • nfc_active_authentication - asserts whether the document NFC chip is original or cloned

Result logic

Passive Authentication and Active Authentication are checked whenever supported by the underlying document. Each check can return a result of clear, consider or null as below:

nfc_passive_authentication nfc_active_authentication
Not supported by document null null
Unable to read data. null null
Failed consider consider
Succeeded clear clear

The individual results are then combined in the issuing_authority breakdown into a single result:

nfc_active_authentication is null nfc_active_authentication is consider nfc_active_authentication is clear
nfc_passive_authentication is null null consider clear
nfc_passive_authentication is consider consider consider consider
nfc_passive_authentication is clear clear consider clear

The overall document verification result is influenced by the issuing_authority breakdown as follows. Note that if fallback to Visual checks is disabled, the Issuing Authority section would be the main driver to the overall result.

Issuing Authority Breakdown Overall Document Verification
null rejected
consider suspected
clear clear

Note that if the document's NFC data contains the applicant's photograph, this photograph will be used in any subsequent facial similarity checks, if configured.

Configuration options

In addition to the NFC verification described in this document, you can configure your account to also trigger Visual Document Verification whatever the issuing_authority breakdown result( clear, consider or null). In those cases, the visual authentication, image integrity and data consistency checks will be performed and the results returned in the respective report breakdowns.

Please contact your Customer Success manager to enable this.

Properties

In the Document check properties an nfc object is returned which includes the NFC extracted document data.

If NFC is not available, no data will be extracted and the nfc object will not be returned.

Onfido

Our solutions

Onfido uses 256-bit SSL encryption 100% of the time on every device.

BSI ISO/IEC27001

Onfido has been certified by BSI to ISO 27001 under certificate number IS 660122.

© Onfido™, 2022. All rights reserved.
Company Registration Number: 07479524.