Skip to content

attestr/kotlin-sample-app

Repository files navigation

Attestr Kotlin Sample App

Platform GitHub GitHub release (latest SemVer including pre-releases)

Installation

Maven users

Add this dependency to your project:

<dependency>
 <groupId>com.attestr</groupId>
 <artifactId>attestr-flowx</artifactId>
 <version>0.6</version>

Gradle users

Add this dependency to your project's build file:

implementation "com.attestr:attestr-flowx:0.6"

Usage

Create new object of AttestrFlowx

  private var attestrFlowx: AttestrFlowx? = AttestrFlowx()

Initialize AttestrFlowx with client_key, handshake_id & activity

/**
 * Initialises an instance of AttestrFlowx
 * @param cl Mandatory client key
 * @param hs Mandatory handshake key
 * @param activity Activity on which flow is to be rendered
 */
attestrFlowx?.init(clientKey, handShakeID, this);

Launch AttestrFlowx with locale, retry and queryParameters

/**
 * This function launches the flow with the following specifications
 * @param lc Mandatory language code eg. 'en' for English.
 * @param retry Mandatory parameter to set retry as true if re-running the flow for a previously used handshake.
 * @param qr Optional query parameters.
 */
attestrFlowx?.launch(locale, retry, qr);

Implement AttestrFlowXEventListener and define success, error and skip handlers

// Implement AttestrFlowXEventListener 

class MainActivity : AppCompatActivity(), AttestrFlowXListener {

    // Replace following with your own implementations
    override fun onFlowXComplete(map: Map<String?, Any>) {
        Toast.makeText(this, "Signature: " + map["signature"], Toast.LENGTH_SHORT).show()
    }

    override fun onFlowXSkip(map: Map<String?, Any?>?) {
        Toast.makeText(this, "Flow skipped", Toast.LENGTH_SHORT).show()
    }

    override fun onFlowXError(map: Map<String?, Any?>) {
        val errorMessage = map["message"] as String?
        Toast.makeText(this, "Error : $errorMessage", Toast.LENGTH_SHORT).show()
    }
}

Version Compatibility

Built for Android API 21+ (Lollipop onwards)

License

attestr-android-sdk is distributed under MIT license. Read more in the LICENSE file.

Contact Us

Write to us at [email protected]