Tap2iD SDK for iOS - Integration

Add the Tap2iD SDK to your iOS project via Swift Package Manager (SPM) using the provided repository URL.

Tap2iD-SDK-iOS on GitHub
Before you start

System Requirements

Your development environment must meet these requirements:

  • 🍎 Supported iOS Versions: iOS 17.0 and later
  • πŸ”¨ Xcode Version: 15.0 or later
  • πŸ“± Hardware Requirements: iPhone 11 or newer with NFC enabled
01

Swift Package Manager

Add the Tap2iD SDK to your Xcode project using Swift Package Manager.

1

Open Xcode

Launch your project in Xcode.

2

Add Package Dependency

Go to File β€Ί Add Package Dependencies… and enter the repository URL below.

Swift Package URL
https://github.com/CredenceID/Tap2iD-VerifierSDK-iOS.git
3

Specify Version

Choose Up to Next Major Version and specify X.X.X as the earliest version.

4

Add to Target

Select Tap2iD-VerifierSDK-iOS and add it to your app target.

β„Ή For troubleshooting, see Apple's Adding Package Dependencies to Your App.
02

Bluetooth Support

Open your project's Info.plist and add these Bluetooth usage description keys to enable BLE communication.

⚠ All three Bluetooth keys are required. The App Store rejects apps without these descriptions.
Info.plist: Bluetooth Keys
<key>NSBluetoothAlwaysUsageDescription</key>
<string>Your app requires Bluetooth access to connect to nearby devices even in the background.</string>

<key>NSBluetoothPeripheralUsageDescription</key>
<string>Your app needs to advertise and communicate with other Bluetooth devices.</string>

<key>NSBluetoothWhenInUseUsageDescription</key>
<string>Your app requires Bluetooth access to connect to nearby devices while in use.</string>
03

NFC Support

NFC requires both a capability entitlement in Xcode and additional keys in Info.plist.

Enable NFC Capability

1

Open your project in Xcode

Select your project in the navigator and click your app target.

2

Go to Signing & Capabilities

Select the Signing & Capabilities tab in the target editor.

3

Add Near Field Communication Tag Reading

Click + and search for Near Field Communication Tag Reading, then add it to your target.

Modify Info.plist

Add the NFC usage description and required identifiers to your Info.plist.

Info.plist: NFC Keys
<key>NFCReaderUsageDescription</key>
<string>Your app requires NFC access to read mobile identity documents.</string>

<key>com.apple.developer.nfc.readersession.iso7816.select-identifiers</key>
<array>
    <string>D2760000850101</string>
</array>

<key>com.apple.developer.nfc.readersession.felica.systemcodes</key>
<array>
    <string>12FC</string>
</array>
04

Add your license key

Generate your license key on the Tap2iD SDK License Key page, then pass it into CoreSdkConfig when you initialize the SDK. Do not hard-code the key. Store it in your project's secrets or environment.

Swift: SDK initialization
let config = CoreSdkConfig(apiKey: "YOUR_API_KEY") // from verify.credenceid.com

Tap2iDVerifySDK.shared.initSdk(config: config) { error, message, profile in
    if let error {
        print("Init failed: (error)")
    } else {
        print("SDK ready")
    }
}
⚠️ Store your license key in Secrets.xcconfig or the iOS Keychain. Do not commit it to source control.
You're all set!
Build and run your project. You can now access all Tap2iD iOS SDK APIs in your application.

Example Usage

Swift: TestSDK.swift
import Tap2iDVerifierSDK

class TestSDK {

    var delegate: Tap2iDVerifySDKDelegate?

    func initSDK(
        apiKey: String,
        result: @escaping (String?, String?, String?) -> Void
    ) {
        let sdkConfig = CoreSdkConfig(apiKey: apiKey)

        Tap2iDVerifySDK.shared.initSdk(config: sdkConfig) { error, message, profile in
            result(error, message, profile)
        }
    }

    func startQrEngagement(
        capturedQr: String,
        result: @escaping (Error?) -> Void
    ) {
        let error = Tap2iDVerifySDK.shared.verifyMdoc(
            engagementConfig: .qrCode(capturedQr),
            delegate: self
        )
        if let error { result(error) }
    }

    func startPdfEngagement(
        pdf417: String,
        result: @escaping (Error?) -> Void
    ) {
        let error = Tap2iDVerifySDK.shared.verifyMdoc(
            engagementConfig: .pdf417(pdf417),
            delegate: self
        )
        if let error { result(error) }
    }

    func startNativeNfcEngagement(
        result: @escaping (Error?) -> Void
    ) {
        let error = Tap2iDVerifySDK.shared.verifyMdoc(
            engagementConfig: .nfc,
            delegate: self
        )
        if let error { result(error) }
    }

    func startExternalNfcReaderEngagement(
        readerDelegate: NfcExternalReaderDelegate,
        result: @escaping (Error?) -> Void
    ) {
        let error = Tap2iDVerifySDK.shared.verifyMdoc(
            engagementConfig: .nfcExternalReader,
            delegate: self,
            readerDelegate: readerDelegate
        )
        if let error { result(error) }
    }

    func stopMonitoring() {
        Tap2iDVerifySDK.shared.stopMonitoring()
    }
}

Tap2iDVerifySDKDelegate

Swift: Verification Delegate
extension TestSDK: Tap2iDVerifySDKDelegate {

    func onVerificationStageStarted(stage: VerificationStage) {
        // Handle verification stage start
    }

    func onVerificationStageError(
        stage: VerificationStage?,
        error: CoreCredenceErrorStruct?
    ) {
        // Handle verification error
    }

    func onVerificationStageCompleted(stage: VerificationStage) {
        // Handle verification stage completion
    }

    func onVerificationCompleted(
        verificationResult: VerificationResult?
    ) {
        // Handle final verification result
    }
}

NfcExternalReaderDelegate

Swift: NFC External Reader Delegate
extension TestSDK: NfcExternalReaderDelegate {

    func didDetectReaders() {
        // External NFC reader detected
    }

    func didDisconnectFromReader() {
        // External reader disconnected
    }

    func didDetectSmartCard() {
        // Smart card detected
    }

    func didDisconnectFromSmartCard() {
        // Smart card disconnected
    }
}

Next steps