1
0 Comments

Getting started with biometric authentication on iOS

Initial Setup
This iOS SDK enables you to add FIDO-certified authentication in your native iOS application without having to redirect the user to any pages outside your application.

For more robust functionality, it is likely that you will need to also leverage a Server SDK. The Server SDK makes requests to LoginID's API easier by leveraging your API Credential. Check out the LoginID Server SDK for a simplified integration.

Create Application on the Dashboard
An application must be created on https://usw1.loginid.io/register/get-started-a in order to correctly configure the iOS SDK.

Once logged into the dashboard, navigate to the Applications tab in the sidebar, select “Add Application,” then select iOS.

In the resulting form, you must create a name for your application. A a Client ID and Base URL is generated for your application, which you will use to configure the SDK.

After entering your application name, you will be prompted to create an API credential. If you have a client-side only application, please skip this step. Otherwise, create an API credential in order to make protected API calls.

NOTE
An API service token must be included on all requests once an API credential is assigned to an application.

Add SDK to Existing Application
This instruction is for configuring your Xcode environment using Cocoapods (Please refer to https://cocoapods.org/ for more information). The LoginID SDK requires min iOS 10 for compatibility.

NOTE
This SDK requires biometrics with a secure enclave that is only available on actual devices with iOS 10 +. Simulated devices are not currently supported.

Add Login SDK framework to your Podfile, then run pod install.

platform :ios, '10.0'

target 'MyTestObjcApp' do
use_frameworks!
#LoginSDK pod install
pod 'LoginSDK','0.90.03gh', :source => 'https://github.com/loginid1/LoginSDKSpecs.git'

your other pods

end

NOTE
iOS mandates adding a usage string with the key NSFaceIDUsageDescription to your app’s info.plist file in order to use FaceID.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSFaceIDUsageDescription</key>
<string>Privacy description regarding to usage of FaceID feature</string>
...
...
</plist>

Note: For Objective-C development, make sure to enable "Embed Swift Standard Libraries" in your build settings to avoid a runtime error

Enable this functionality by navigating to: Build Settings > Build Options > Always Embed Swift Standard Libraries "YES"

Create an SDK Instance
Swift
Objective-C
import LoginIDSDK
The LoginID API must be called before any other APIs. You should call this API within your AppDelegate's didFinishLaunchingWithOptions method.

Swift
Objective-C
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

    // clientId example 032690b3-9bc4-4602-87c1-60c1fae782f2
    let clientId="<your api key>"
    // baseURL example https://060ce487-b934-43d0-a925-b66e80c7532f.native-api.auth.loginid.id
    let baseURL="<your base url"

    LoginApi.client.configure(clientId: clientId, baseURL: baseURL)
    ...
    ...
}

...
...

on August 11, 2021