Android
Adding the ReadyRemit SDK Package to Your Android Project
In this guide, you will learn how to integrate the ReadyRemit SDK into your Android app.
Step 1 - Prepare for the ReadyRemit SDK
-
Make sure that your app's minimum Android API level is 26 or higher. This can be found in the
build.gradlefile. Depending on your setup this might be defined in thebuild.gradlefile at the Module level or at the Project level.android { compileSdkVersion 35 defaultConfig { ... minSdkVersion 26 targetSdkVersion 35 } // Java and Kotlin versions compatibility compileOptions { sourceCompatibility JavaVersion.VERSION_17 targetCompatibility JavaVersion.VERSION_17 } kotlinOptions { jvmTarget = '17' } }
-
Add classpath dependencies to the
build.gradleat the Project level.buildscript { ... ext { ... kotlinVersion = "2.0.20" } dependencies { ... classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion") classpath 'com.android.tools.build:gradle:7.4.2' } } allprojects { repositories { google() mavenCentral() jcenter() maven { url 'https://maven.google.com' } maven { url "https://jitpack.io" } } }
Newer Gradle versions 8.0 or above.if you are using a newer gradle structure of 8.0 or above, you should not add this segment of code.
allprojects { repositories { google() mavenCentral() jcenter() maven { url 'https://maven.google.com' } maven { url "https://jitpack.io" } } }instead open your settings.gradle and add the following:
dependencyResolutionManagement { repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) repositories { google() mavenCentral() jcenter() maven { url 'https://maven.google.com' } maven { url "https://jitpack.io" } } }also in your gradle.properties add this line:
android.enableJetifier=true
- Add the following
applystatements to the top of yourbuild.gradlefile at the Module level:
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'Step 2 - Install the ReadyRemit SDK
Installing via binary
- Download the
readyremit.aarfrom the Releases page on Github - Add the .aar file to the folder your_app_root/app/libs
- Add the path as a dependency to your app's
build.gradlefile a the Module level:
dependencies {
...
// ReadyRemit SDK
implementation files('libs/readyremit.aar')
}- Add missing third-party dependencies to your app's
build.gradlefile at the Module level:
dependencies {
...
// ReadyRemit SDK
implementation files('libs/readyremit.aar')
// The following are required to run the SDK
// please add the ones your project does not have
// Core
implementation "androidx.core:core-ktx:1.10.0"
// UI
implementation "androidx.appcompat:appcompat:1.6.1"
implementation "com.google.android.material:material:1.9.0"
// Navigation
implementation "androidx.navigation:navigation-fragment-ktx:2.6.0"
implementation "androidx.navigation:navigation-ui-ktx:2.6.0"
implementation "androidx.navigation:navigation-compose:2.6.0"
// Compose
implementation platform("androidx.compose:compose-bom:2023.06.01")
implementation "androidx.compose.compiler:compiler:1.3.2"
implementation "androidx.compose.runtime:runtime:1.3.2"
implementation "androidx.compose.material:material:1.3.2"
implementation "androidx.compose.ui:ui-tooling"
implementation "androidx.compose.ui:ui-tooling-preview"
implementation "androidx.lifecycle:lifecycle-runtime-compose:2.6.0"
implementation 'com.github.DImuthuUpe:AndroidPdfViewer:3.1.0-beta.1'
// Kotlin
implementation platform("org.jetbrains.kotlin:kotlin-bom:1.8.22")
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android"
// OkHttp
implementation "com.squareup.okhttp3:okhttp:4.11.0"
implementation "com.squareup.okhttp3:logging-interceptor:4.11.0"
// Profiler
implementation "com.localebro:okhttpprofiler:1.0.8"
// Retrofit
implementation "com.squareup.retrofit2:retrofit:2.9.0"
implementation "com.squareup.retrofit2:converter-gson:2.9.0"
implementation "com.squareup.retrofit2:converter-moshi:2.9.0"
// Moshi
implementation "com.squareup.moshi:moshi:1.14.0"
implementation "com.squareup.moshi:moshi-adapters:1.14.0"
kapt "com.squareup.moshi:moshi-kotlin-codegen:1.14.0"
// Dagger
implementation "com.google.dagger:dagger:2.50"
implementation "com.google.dagger:dagger-android:2.50"
implementation "com.google.dagger:dagger-android-support:2.50"
kapt "com.google.dagger:dagger-compiler:2.50"
kapt "com.google.dagger:dagger-android-processor:2.50"
// Mixpanel
implementation "com.mixpanel.android:mixpanel-android:7.4.1"
// Launch Darkly
implementation "com.launchdarkly:launchdarkly-android-client-sdk:5.0.0"
}- Download
visa-sensory-branding-sdkfrom Github. - Add the
.aarfile to the folderyour_app_root/app/libs. - Add the path as a dependency to your app's
build.gradlefile a the Module level:
dependencies {
...
implementation files ('libs/visa-sensory-branding-2.0.aar')
}Instaling via Gradle/Maven
- Add the SDK as a dependency to your app's
build.gradlefile a the Module level:
dependencies {
...
// ReadyRemit SDK
implementation "io.github.brightwellpayments:ReadyRemitSDK:9.3"
}
Build features
Add the buildFeatures and composeOptions blocks in your app’s build.gradle file at the Module level:
android {
...
// UI building features
buildFeatures {
dataBinding true
viewBinding true
buildConfig true
compose true
}
// add composeOptions in order to support Jetpack Compose
composeOptions {
kotlinCompilerExtensionVersion "1.5.14"
}
}Step 3 - Retrieve an auth token and submit a transfer
The access token callback should return a ReadyRemitAuth object that includes the access token. The access should be obtained by your server (see Server side integration for more details) and provided to your app.
To request an Auth Token, use the following code.
private fun requestReadyRemitAccessToken(callback: ReadyRemitAuthCallback) {
// On success
callback.onAuthSucceeded(
ReadyRemitAuth(
// Access token from an API call to your backend, or from memory storage
accessToken,
"" // Empty String
)
)
// On failure (error code should be returned from your server if the submission fails)
callback.onAuthFailed()
}The submit transfer callback operation performs a call to request the transfer. If successful, it will return a transfer id to your server.
To submit a transfer, use the following code.
private suspend fun submitReadyRemitTransfer(
request: ReadyRemitTransferRequest,
callback: ReadyRemitTransferCallback
) {
// Call to your server to submit the transfer
// Example: response = api.SubmitTransfer(request);
// On success (transfer ID should be returned from your server)
callback.onTransferSucceeded(transferId)
// On failure (error code should be returned from your server if the submission fails)
callback.onTransferFailed(errorCode)
}
SECURITY WARNINGWe strongly recommend not storing the access token in any long-term storage. If obtained maliciously, this token can be used to view your user's confidential financial information.
Step 4 - Launch SDK
To launch the ReadyRemit SDK, use the following code. It should be triggered from an Activity typically inside a button's OnClick Listener.
val sdkConfig = ReadyRemit.Config.Builder(application)
.useEnvironment(environmentManager.environment())
.useAuthProvider { callback ->
// your authentication provider function
}
.useTransferSubmitProvider { request, callback ->
// submitReadyRemitTransfer(request, callback)
}
.setEventListener { event: ReadyRemitEvent ->
// trigger something
}
.useHomeScreenTexts(
ReadyRemitHomeScreenTexts(
title = ReadyRemitHomeScreenTexts.HomeTitle.InternationalAndDomestic,
subTitle = ReadyRemitHomeScreenTexts.HomeSubtitle.FriendsAndFamilyAbroad
)
)
.setLocale(ReadyRemitLanguage.enUS)
.useRSP(Rsp.VISA)
.useSingleMethod(TransferType.BANK_ACCOUNT)
.useBalanceCheck(
ReadyRemitBalanceCheck(
alias = "Everyday Checking",
balance = balanceTyped.toBigDecimal(),
last4 = "0352",
externalId = "external-id"
)
)
.build()
// Start the SDK
ReadyRemit.startSDK(this@MainActivity, config)(Optional) Style the ReadyRemit SDK
- In the root of your Android project create a new
Values Resource File(ex: theme_readyremit.xml). - Use the following code as a template and fill in any colors you'd like to override:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.ReadyRemit" parent="Theme.ReadyRemit.Light">
<item name="rrmBackgroundColor">#F3F4F6</item>
<item name="rrmForegroundColor">#FFFFFF</item>
<item name="rrmButtonTextColor">#FFFFFF</item>
<item name="rrmButtonColor">#743FC9</item>
<item name="rrmDangerColor">#AA220F</item>
<item name="rrmDangerLightColor">#F4E9E7</item>
<item name="rrmDividerColor">#E2E2E2</item>
<item name="rrmIconColor">#444444</item>
<item name="rrmInputLineColor">#858585</item>
<item name="rrmPrimaryColor">#934AE0</item>
<item name="rrmPrimaryLightColor">#F3EDFB</item>
<item name="rrmSuccessColor">#008761</item>
<item name="rrmTextColor">#0E0F0C</item>
<item name="rrmTextSecondaryColor">#454545</item>
</style>
</resources>- Navigate to the project's resource folder. The path should be something like:
MyProject/app/src/main/res - Ensure that there is a folder named
values-night. If this folder doesn't exist, create it. - Inside the
values-nightfolder, create an XML file with the exact same name as the original theme used for the light mode. - Open the project in Android Studio. In the res/values directory, you will find a directory for these themes. There will be one for light mode and one for dark mode (indicated by
nighttag). - In the dark mode theme file, add the following structure:
Important• Make sure to set the parent attribute to
Theme.ReadyRemit.Dark.• If you're only using the light mode in your application, you can copy the same colors from the theme used for the light mode. If you're using the dark mode, make the necessary color modifications here.
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.ReadyRemit" parent="Theme.ReadyRemit.Dark">
<item name="rrmBackgroundColor">#111111</item>
<item name="rrmForegroundColor">#1F1F1F</item>
<item name="rrmButtonTextColor">#FFFFFF</item>
<item name="rrmButtonColor">#558CF4</item>
<item name="rrmDangerColor">#AA220F</item>
<item name="rrmDangerLightColor">#201311</item>
<item name="rrmDividerColor">#313131</item>
<item name="rrmIconColor">#7E7E7E</item>
<item name="rrmInputLineColor">#505050</item>
<item name="rrmPrimaryColor">#558CF4</item>
<item name="rrmPrimaryLightColor">#83ACF7</item>
<item name="rrmSuccessColor">#008761</item>
<item name="rrmTextColor">#E3E3E3</item>
<item name="rrmTextSecondaryColor">#B0B0B0</item>
</style>
</resources> - Update the configuration object to use the new theme.
ReadyRemit.Config.Builder(application)
.useDefaultTheme(R.style.my_awesome_style)(Optional) Closing ReadyRemitSDK
If you wish to gracefully close the ReadyRemitSDK at any point in your code, you can achieve this with the following method:
fun closeReadyRemitSDK() {
ReadyRemit.close()
}(Optional) Inactivity Detector
If you prefer to automatically close the ReadyRemitSDK when your users are inactive, you can add it to your Configuration object
ReadyRemit.Config.Builder(application)
.setCloseAfter(
closeAfter = 240,
onCloseAfter = { Log.d("ReadyRemitSDK", "Closed due inacitivity") }
)(For KYC users only) Implement KYC
If you wish to use the ReadyRemitSDK with the KYC feature, you need to add the camera permission in your AndroidManifest.xml file, since it will require scan the user documents.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.your.package">
...
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA"/>
<uses-feature android:name="android.hardware.camera" android:required="false" />
</manifest>Updated about 2 months ago
