Argyle’s Android Link SDK provides a way to integrate Link into your Android app.
Requirements:
android {
compileSdk 34
defaultConfig {
minSdk 26
...
}
...
}
- Add the following line within the dependencies of your app
build.gradle
configuration file:
dependencies {
implementation 'com.argyle:argyle-link-android:5.+'
}
- Sync your Android project to import the build configuration changes
- Log-in to Console and retrieve a copy of your Link key
- Create a user token:
- New users
- Create a new user by sending a POST to the users endpoint of the Argyle API
- The response payload will include an
id
anduser_token
- Save the
id
for quickly creating user tokens for this user in the future - Initialize Link by passing the
user_token
as the value for theuserToken
parameter
- Returning users
- Send a POST request to the user-tokens endpoint of the Argyle API
- Include the
id
of the user in the request body as a JSON object in the format{"user": "<id>"}
- Include the
- A
user_token
will be included in the response payload - Initialize Link by passing the
user_token
as the value for theuserToken
parameter
- Send a POST request to the user-tokens endpoint of the Argyle API
- Initialize Link using the Link key and user token.
Example Link initialization for Android:
val config = LinkConfig(
linkKey = "YOUR_LINK_KEY",
userToken = "USER_TOKEN",
sandbox = true // Set to false for production environment.
)
// (Optional) Limit Link search to these Items:
config.items = listOf("item_000001422", "item_000025742")
// (Optional) Callback examples:
config.onAccountConnected = { data ->
Log.d("Result", "onAccountConnected $data")
}
config.onAccountError = { data ->
Log.d("Result", "onAccountError $data")
}
config.onDDSSuccess = { data ->
Log.d("Result", "onDDSSuccess $data")
}
config.onDDSError = { data ->
Log.d("Result", "onDDSError $data")
}
config.onTokenExpired = { handler ->
// generate your new token here
// handler(newToken)
}
ArgyleLink.start(context, config)