The latest source code of the Keyri iOS SDK can be found here: https://github.com/Keyri-Co/keyri-ios-whitelabel-sdk/releases


CocoaPods is a dependency manager for Cocoa projects. For usage and installation instructions, visit their website. To integrate Keyri iOS SDK into your Xcode project using CocoaPods, specify it in your Podfile:


Provisioning Keyri Config Parameters

Supply these three parameters to your app: - appkey - rpPublicKey - callbackUrl

And then use them to configure the SDK before initialization:


To handle Universal Links (e.g., for QR login straight from the user's built-in camera app) you need to add the Associated Domains Entitlement to your App.entitlements. To set up the entitlement in your app, open the target’s Signing & Capabilities tab in Xcode and add the Associated Domains capability or if you already have entitlements you can modify your App.entitlements file to match example:


This will handle all links with such scheme: https://{domainName}/application?sessionId=324e23.

In the AppDelegate where the processing of links is declared, you need to add handlers in the application(_:continue:restorationHandler:) method:


The last thing you need to do in order for your universal links to be processed is to create the associations for each of the declared hosts for handling in JSON file (https://{yourDomainName}/.well-known/apple-app-site-association) as described here: https://developer.apple.com/documentation/Xcode/supporting-associated-domains

Option 1: Use the built-in QR authentication UI/UX

Use the built-in QR authentication to give SDK perform signup or login user under the hood


Option 2: Build a custom authentication/authorization UI/UX

Alternatively, if you want to provide a custom authentication/authorization UI/UX, use the following methods:

  • onReadSessionId()- call it after retrieving the sessionId from QR-code or deep link.
  • signup() - Must be called after onReadSessionId(). This method is needed to create a user for Desktop agent (i.e., if the user does not already have an account and is trying to register). Pass username, sessionId, service, and any custom param needed to work with your identity management system.
  • login() - this method needed to login user for Desktop agent. Must be called after onReadSessionId(). Pass public account identifies (e.g., username), sessionId, service and custom param.
  • mobileSignup() - method to create user on mobile device.
  • mobileLogin() - method to login user on mobile device.

Manage Accounts

  • accounts() - retrieve all public accounts from storage.
  • removeAccount() - remove public account from storage

Integration into an existing system

To use Keyri SDK with an existing authorization system, there is no need to remove the old one. You can easily integrate Keyri SDK into your system. To do this, first, add the SDK dependency to your project as shown in the Integration section.


To adapt an existing account to the SDK, you need to check if the account exists in the SDK local storage. Call the accounts() method, which will return a list of PublicAccount objects. Look up your account by unique user ID or any other unique ID equal to custom field of PublicAccount object.

Call the mobileSignup() method if no account is found, passing the username and the user's unique ID or any other unique ID as the custom argument. After that, the user will be created and the method will return the AuthMobileResponse, which contains User entity, Auth Token and Refresh Token as shown below:



If the needed PublicAccount is present in the SDK storage, call the mobileLogin() method, passing this account to it. You will be returned the user entity, token, and refresh token as in mobileSignup(). AuthMobileResponse will be returned, so you need to encrypt and save Auth Token and Refresh Token and use them as you did before (Bearer token, etc.).

Logout and account deletion

When you want to log out user from the system, remove the account from the Keyri SDK by calling removeAccount() method and passing in the PublicAccount.

Updated 20 Jan 2022
Did this page help?