Android

Follow these instructions to set up your Android integration.

Setup

Android Link SDK provides a way to integrate Argyle Link into your Android app.

The SDK supports API level 23 and above (distribution stats).

📘

Argyle recommends that you lock your app to portrait orientation.

❗️

Important: When using tools like Proguard to obfuscate your code, make sure to exclude Android Link SDK package (com.argyle.*) from the process, it may cause unexpected runtime issues otherwise. You can do this by adding this line to your proguard-rules.pro:-keep class com.argyle. { *; }

The target configuration is currently set to:

  • minSdkVersion = 23
  • Kotlin = 1.6.21
  1. Add the SDK dependency.
dependencies {
    implementation 'com.argyle:argyle-plugin-android-source:4.x.x'
}
  1. Create the SDK configuration.
val config = ArgyleConfig.Builder()
  .loginWith("YOUR_LINK_KEY", "https://api-sandbox.argyle.com/v1", "USER_TOKEN")
  //.linkItems(arrayOf("lyft", "uber"))
  .setCallbackListener(object : Argyle.ArgyleResultListener {

    override fun onUserCreated(userToken: String, userId: String) {
      Log.d("Result", "onUserCreated:  userId: $userId, userToken: $userToken")
    }

    override fun onAccountCreated(accountId: String, userId: String, linkItemId: String) {
      Log.d("Result", "onAccountCreated: accountId: $accountId, userId: $userId, linkItemId: $linkItemId")
    }

    override fun onAccountConnected(accountId: String, userId: String, linkItemId: String) {
      Log.d("Result", "onAccountConnected: accountId: $accountId, userId: $userId, linkItemId: $linkItemId")
    }

    override fun onAccountUpdated(accountId: String, userId: String, linkItemId: String) {
      Log.d("Result", "onAccountUpdated: accountId: $accountId, userId: $userId, linkItemId: $linkItemId")
    }

    override fun onAccountRemoved(accountId: String, userId: String, linkItemId: String) {
      Log.d("Result", "onAccountRemoved: accountId: $accountId, userId: $userId, linkItemId: $linkItemId")
    }

    override fun onAccountError(accountId: String, userId: String, linkItemId: String) {
      Log.d("Result", "onAccountError: accountId: $accountId, userId: $userId, linkItemId: $linkItemId")
    }

    override fun onPayDistributionSuccess(accountId: String, userId: String, linkItemId: String) {
      Log.d("Result", "onPayDistributionSuccess: accountId: $accountId, userId: $userId, linkItemId: $linkItemId")
    }

    override fun onPayDistributionError(accountId: String, userId: String, linkItemId: String) {
      Log.d("Result", "onPayDistributionError: accountId: $accountId, userId: $userId, linkItemId: $linkItemId")
    }  

    override fun onError(error: ArgyleErrorType) {
      Log.d("Result", "onError: error: $error")
    }

    override fun onTokenExpired(handler: (String) -> Unit) {
      handler("new_token")
    }
    
    override fun onUIEvent(name: String, properties: Map<String, Any>) {
      Log.d("Result", "onUIEvent: $name, properties: $properties")
    }

    override fun onClose() {
      Log.d("Result", "onClose")
    }
  })
  .build()

📘

The API host in this SDK configuration example is set to the Argyle Sandbox API (https://api-sandbox.argyle.com/v1). It's a good idea to test your implementation in Sandbox mode first, then change this to the Production API (https://api.argyle.com/v1) when you are ready to go live.

  1. Start the flow.
Argyle.instance.init(config);
Argyle.instance.startSDK(this)

Closing Link programmatically

Normally, the user closes Link but you can also close it by calling Argyle.instance.close().

🚧

We strongly recommend upgrading the SDK as soon as there is a new version available. Doing so will help you provide the best Argyle Link experience in your application.

To receive notifications when a new release is issued you can watch for releases on our repositories.

Configuration

Argyle Link provides multiple configuration options and callbacks that customize how this UI element functions in your application. The only argument that is mandatory when invoking Argyle Link is the linkKey, which you can find in the Argyle Console.

By default, anytime Argyle Link is initialized, it will be treated as a new session for a new user. To ensure your users retain their previous state in Argyle Link when it is re-initialized for them, your application must use the userToken parameter.

For a full list of Link configuration parameters, see the Link reference.

User tokens

User tokens are temporary access keys that let you start Argyle Link for an existing user.

They are JWT tokens that contain an expiry date you can use to determine if you need to create a new user token. Newly issued tokens expire in 30 days. You can always decode the token to find out the exact expiration date (check exp field).

You can create user tokens using the /user-tokens endpoint.

Make sure that you request user tokens on your server-side and your client_id and client_secret are never exposed on the front-end.

Callbacks

For a full list of callbacks, see the Link reference.

Upgrade

See the Link SDK for Android upgrade guide for instructions on upgrading your integration.


Did this page help you?