Skip to main content

iOS SDK

Initial Setup#

The LoginID 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 the LoginID Dashboard 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. We generate a Client ID and Base URL 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#

warning

We've recently made some significant improvements to our iOS SDK and we are working on getting this to a public repository. For now, please contact support@loginid.io and we can assist you with mobile integrations.

Create an SDK Instance#

import LoginIDSDK

The LoginID API must be called before any other APIs. You should call this API within your AppDelegate's didFinishLaunchingWithOptions method.

@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 client id>"
        // 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)
        ...
        ...
    }
...    

API Reference#

registerWithFido2#

Sign up a user for FIDO authentication.

registerWithPassword#

Creates a user account with a password (not recommended). If leveraging this method, users should be migrating to use a FIDO authenticator, then have their password revoked.

authenticateWithFido2#

Authenticate a previously registered user through FIDO2.

authenticateWithPassword#

Authenticate a previously registered user using username and password.

confirmTransaction#

Coming Soon

isLoggedIn#

Check if a given user is currently logged in.

logout#

Deprecated Methods#

The iOS SDK previously had the following methods:

  • .register()
  • .login()

The methods have been deprecated, as the type of authenticator is now specified in the register and authenticate methods.