Flutter
System Requirements
- Android API level 23 or higher
- AndroidX compatibility
- iOS 14+
- Swift 5+
- Apple A7 chip or newer (The A7 shipped with the iPhone 5s)
To integrate the Keyri project, run this command in terminal in root of the project directory:
The SDK can then be imported into any dart file as follows:
The descriptions of the individual functions of the Keyri SDKs can be found here: https://docs.keyri.com/ios https://docs.keyri.com/android https://pub.dev/documentation/keyri/latest/
Below is an example code block which utilizes the Keyri library in 2 common ways:
This function allows Keyri to handle everything for you - simply pass in the User Id, App Key, and Payload and Keyri will handle displaying a built-in QR scanner, get the session information, present a Confirmation Dialogue to the user, and finalize the details with the API.
This function can be used if you'd like to present your own custom Scanner and/or Confirmation dialogue to the user. This also works for DeepLinks/AppLinks (see below) Calling this function returns a Session object, which can be handled by:
- Automatically confirming (via confirmSession())
- Presenting your own custom confirmation screen to the user
- Presenting the built-in Keyri confirmation screen (initializeDefaultScreen()) - this method is used below
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 file. 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 this example:
This will handle all links with the following scheme: https://{yourCompany}.onekey.to?sessionId={sessionId}
Note: Keyri will create your https://{yourCompany}.onekey.to page automatically once you configure it in the dashboard
In the AppDelegate where the processing of links is declared, you need to add handlers in the application(_:continue:restorationHandler:) method:
Note: Keyri will set up the required /.well-known/apple-app-site-association JSON at your https://{yourSubdomain}.onekey.to page as required by Apple to handle Universal Link handling. Details on this mechanism are described here: https://developer.apple.com/documentation/Xcode/supporting-associated-domains
To handle Android App Links (e.g., for QR login straight from the user's built-in camera app) you need to define the following intent-filter block in your AndroidManifest.xml:
In the activity where the processing of links is declared, you need to add handlers in the onNewIntent() and onCreate() methods, and pass `sessionId` to `easyKeyriAuth` method: