Getting started

Let's get started!

In this getting started guide, we will add the Keyless SDK to your Mobile application project. This will allow you to enroll and authenticate users with Keyless.

Prerequisites

Android
iOS
Your project must target API level 23 or later
  • Your project must target iOS 12.4 or later.
  • Enable camera permissions by adding the Privacy - Camera Usage Description key in your project’s Info.plist
  • 1
    <key>NSCameraUsageDescription</key>
    2
    <string>Keyless needs access to your camera to enroll and authenticate you. Keyless cannot be used without your camera. Please allow camera permissions.</string>
    Copied!
  • Enable the Background processing mode under Signing & Capabilities/Background Modes.
    Then, add the following in your project’s Info.plit (in XCode, under the key Permitted background task scheduler identifiers):
    1
    <key>BGTaskSchedulerPermittedIdentifiers</key>
    2
    <array>
    3
    <string>YOUR APP IDENTIFIER</string>
    4
    </array>
    Copied!

Installation

Android - Gradle
iOS - Cocoapods
Add the following within the repositories section of the build.gradle file of your Android application. Replace the YOUR_CLOUDSMITH_TOKEN text with the CloudSmith token for partners provided to you by Keyless.
1
allprojects {
2
repositories {
3
google()
4
jcenter()
5
6
maven {
7
url "https://dl.cloudsmith.io/YOUR_CLOUDSMITH_TOKEN/keyless/partners/maven/"
8
}
9
}
10
}
Copied!
Add the following to the dependencies block of your project build.gradle file, typically app/build.gradle.
app/build.gradle
1
dependencies {
2
// ...
3
4
implementation 'io.keyless:keyless-sdk:+'
5
}
Copied!
Add the following to the android block of the same file
app/build.gradle
1
android {
2
// ...
3
4
compileOptions {
5
sourceCompatibility JavaVersion.VERSION_1_8
6
targetCompatibility JavaVersion.VERSION_1_8
7
}
8
9
// add the following only if you're using Kotlin
10
kotlinOptions {
11
jvmTarget = "1.8"
12
}
13
}
Copied!
Step 1: Create a Podfile if you don’t already have one
1
$ cd your-project-directory
2
$ pod init
Copied!
Step 2: Setup Cocoapods to use your Cloudsmith credentials, by running the following commands and replacing YOUR_CLOUDSMITH_TOKEN with the Cloudsmith token for partners provided you by Keyless.
1
git config --global credential.helper store
2
echo "https://token:[email protected]" >> ~/.git-credentials
Copied!
Step 3: Add the KeylessSDK pod to your Podfile
1
# This is the Keyless repository for partners
2
source 'https://dl.cloudsmith.io/basic/keyless/partners/cocoapods/index.git'
3
4
target 'MyApp' do
5
use_frameworks!
6
7
# Add the Keyless pod
8
pod 'KeylessSDK'
9
end
Copied!
Step 4: Add the following at the bottom of the same file
1
post_install do |installer|
2
installer.pods_project.targets.each do |target|
3
target.build_configurations.each do |config|
4
config.build_settings['ENABLE_BITCODE'] = 'NO'
5
end
6
end
7
end
Copied!
Step 5: Install the pods. If pod prompts you for authentication insert the string token as your username and then fill in YOUR_CLOUDSMITH_TOKEN as the password.
1
$ pod install
2
3
Analyzing dependencies
4
Cloning spec repo `cloudsmith-basic-keyless-partners-cocoapods-index` from `https://dl.cloudsmith.io/basic/keyless/partners/cocoapods/index.git`
5
Username for 'https://dl.cloudsmith.io': token
6
Password for 'https://dl.cloudsmith.io': YOUR_CLOUDSMITH_TOKEN
Copied!

Configuration

Now everything should be set to start using the Keyless SDK.
Android
iOS
All you need to do to configure the Keyless SDK, is to create an instance object of Keyless.Configuration and pass it in to Keyless.configure method.
1
val configuration = Keyless.Configuration(
2
apiKey = "YOUR_KEYLESS_API_KEY",
3
hosts = ["YOUR_HOSTS"],
4
numberOfEnrollmentCircuits = 50)
5
6
Keyless.configure(configuration: configuration)
Copied!
All you need to do to configure the Keyless SDK, is to create an instance object of Keyless.Configuration and pass it to the Keyless.configure method, typically this in done in your app’s application(:didFinishLaunchingWithOptions: method:).
1
let configuration = Keyless.Configuration(
2
APIKey: "YOUR_KEYLESS_API_KEY",
3
hosts: ["YOUR_HOSTS"],
4
numberOfEnrollmentCircuits: 50)
5
6
if let error = Keyless.configure(configuration: configuration) {
7
print("Keyless.Configure failed with error: \(error)")
8
}
Copied!
Last modified 21d ago