Identity SDK for iOS
This guide explains how to integrate the Identity SDK into your iOS project.
You can find a sample project demonstrating the integration here.
Prerequisites
-
Cocoapods: Make sure you have Cocoapods installed on your machine.
-
Credentials: Make sure you are provided with
PKB_PODS_SECRETto integrate Peekaboo Connect Pods.
1. Project Setup
a. Add Env file
Create .pkb-env file in the root of your project to include configs:
PKB_PODS_SECRET=****************************************************
b. Pod Integration
i. Integration through Cocoapods
Configure Pod File
- Load env in Pod File
Add the following configurations in your app's Podfile file start:
require 'dotenv'
Dotenv.load('.pkb-env')
...
You can load env in cli before pod install by running source .pkb-env instead of loading in Podfile.
- Add Pods
Add the following configurations in your app's Podfile file:
pod 'PeekabooConnectCore', :http => "https://pkb-partner-config.peekaboo.guru/asset/download/PeekabooConnectCore.zip?module=PeekabooConnectCore&platform=ios&version=<PKB_CORE_VERSION>&secret="+ENV['PKB_PODS_SECRET']
pod 'FetchskyIdentity', :http => "https://pkb-partner-config.peekaboo.guru/asset/download/FetchskyIdentity.zip?module=FetchskyIdentity&platform=ios&version=<IDENTITY_VERSION>&secret="+ENV['PKB_PODS_SECRET']
PKB_PODS_SECRET is fetched from .pkb-env.
Make sure IDENTITY_VERSION is the latest provided version of the sdk.
Make sure PKB_CORE_VERSION is always in sync with the version of the identity sdk.
ii. Manual Integration
-
Download Modules from the links
https://pkb-partner-config.peekaboo.guru/asset/download/PeekabooConnectCore.zip?module=PeekabooConnectCore&platform=ios&version=<PKB_CORE_VERSION>&secret="+ENV['PKB_PODS_SECRET']https://pkb-partner-config.peekaboo.guru/asset/download/FetchskyIdentity.zip?module=FetchskyIdentity&platform=ios&version=<IDENTITY_VERSION>&secret="+ENV['PKB_PODS_SECRET']
The core frameworks are mandatory and must be integrated into your project.
Update Info.plist
Add the following configurations in your app's Info.plist file if not already present:
<key>NSCameraUsageDescription</key>
<string>Camera is required for identity verification.</string>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
2. Update AppDelegate.swift
Add the following variable in your app's AppDelegate file:
var window: UIWindow?
3. Initialize Module
a. Initializing FetchskyIdentity
To initialize the FetchskyIdentity module in your iOS project, follow these steps:
- Import frameworks in your view controller:
import PeekabooConnectCore // for delegate
import FetchskyIdentity
- Conform to the
PeekabooConnectControllerDelegateprotocol in your view controller:
class ViewController: UIViewController, PeekabooConnectControllerDelegate {
// ...
}
- Implement the
peekabooConnectControllerDidExit(withData:)method to handle the data received from Peekaboo Connect:
func peekabooConnectControllerDidExit(withData data: [AnyHashable : Any]) {
// Handle the received data here
print("Received Data From Identity", data["module"]!, data["data"]!)
}
- Initialize the
FetchskyIdentitymodule with the desired initial properties:
let initialProperties: NSDictionary = [
"fontFamily": "<your-font-family>"
// Add more properties here
]
// initialize view controller
let identityViewController = FetchskyIdentity(initialProperties: initialProperties).ViewController()
identityViewController.delegate = self
// present it as modal
identityViewController.modalPresentationStyle = .fullScreen
present(identityViewController, animated: true)
- Run your iOS project and test the integration with Peekaboo Connect Identity.