iOS SDK Integration Guide

Welcome to the iOS SDK integration guide. Follow these steps to seamlessly integrate our Digital Identity solution through our iOS SDK for secure and efficient validation of your users by identity flows.

Prerequisites

  1. Account Creation: In order to perform an integration in any of our services, you must have a Truora account. Your Truora sales representative will provide you with one, or you can create one for free.

  2. Create a Truora API Key: In order to perform an integration in any of our services, you must have a Truora API key. Follow this guide to create your Truora API key.

  3. Create a Digital Identity Web Flow: For instructions on how to create a Web Flow, please refer to the Digital Identity Verification Flow guide.

  4. Create a Web Integration Token: For instructions on how to generate a token, please refer to the How to create a Web Integration Token guide.


iOS SDK Documentation

Usage

To use the iOS SDK, you will need the following inputs:

  • Token: Web Integration Token generated in Prerequisite 4.

Additionally, the class that utilizes the SDK must inherit from the protocol TruoraSDKDIDelegate to handle the final events of the processes, such as stepsCompleted, processSucceeded, and processFailed.

The difference between stepsCompleted and processSucceeded | processFailed is that the process, depending on its configuration, may end the user experience in the flow with a final status or not (due to async steps).

Requirements

  • Swift: >= 5.9
  • iOS: >= 14.0

Installation

The SDK is available for installation via Swift Package Manager (SPM).

  1. Add package dependency:

    sample image

  2. Paste repository URL to get the package:

    sample image

  3. Select project to add:

    sample image
    sample image

And it’s ready to use

sample image

Example in Swift

TruoraSampleApp

import UIKit
import TruoraSDK

class ViewController: UIViewController, TruoraSDKDIDelegate {
    private var truoraSDK: TruoraSDK?

    override func viewDidLoad() {
        super.viewDidLoad()

        setupTruoraSDK()
    }

    private func setupTruoraSDK() {
        truoraSDK = TruoraSDK(frame: view.bounds)

        guard let truoraSDK = truoraSDK else {
            print("Error creating TruoraSDK instance")
            return
        }

        truoraSDK.delegateDI = self
        view.addSubview(truoraSDK)

        let diInput = LoadFrontendInput(token: "YOUR_TOKEN_HERE")

        do {
            try truoraSDK.LoadDI(input: diInput)
        } catch {
            handleError(error: error as? TruoraError ?? TruoraError.unknown)
        }
    }

    // MARK: - TruoraSDK callbacks
    func close() {
        truoraSDK?.removeFromSuperview()
    }

    func handleError(error: TruoraError) {
        print("Error occurred: \(error.localizedDescription)")
    }

    func stepsCompleted(result: TruoraResultDI) {
        print("Steps completed successfully with result: \(result)")
    }

    func processSucceeded(result: TruoraResultDI) {
        print("Process succeeded with result: \(result)")
    }

    func processFailed(result: TruoraResultDI) {
        print("Process failed with result: \(result)")
    }
}

With this setup, you can now test the Digital Identity (DI) feature in a Swift app! 😃