Parakey SDK for Android
The Parakey SDK allows your users to access features of the Parakey ecosystem within your application.
You need to be invited in order to access the SDK. Contact Parakey to request access.
Installation
The SDK is hosted in a private Github repository.
Create a Personal Github access token (classic) at Github>User>Settings>Developer settings> Personal access tokens. The token needs package read access only.
Export the token along with your username in your shell configuration file (e.g. .zshrc)
export GITHUB_USER=<your username>
export GITHUB_TOKEN=<your personal access token>Content copied to clipboardAdd the Github as a maven repository in the root level
build.gradle
allprojects {
repositories {
google()
mavenCentral()
maven {
url = uri("https://maven.pkg.github.com/parakey-ab/parakey-sdk-android")
credentials {
username = System.getenv("GITHUB_USER")
password = System.getenv("GITHUB_TOKEN")
}
}
}
}Content copied to clipboardAdd a dependency on the SDK in your module level
build.gradle
dependencies {
implementation 'co.parakey:sdk:<latest version>'
}Content copied to clipboardThe latest version can be found under Packages in the Github repo. Beta versions are not recommended for production use.
Example usage
class App : Application() {
override fun onCreate() {
super.onCreate()
Parakey.initialize(this)
MainScope().launch {
val tokenBundle = findTokenBundle()
var error = Parakey.configure(tokenBundle)
if (error == null) {
error = Parakey.showScan()
}
if (error != null) {
// handle ParakeyError
}
}
}
private suspend fun findTokenBundle(): String {
// fetch token bundle from Parakey API or from local storage
}
}
Content copied to clipboard