This is the official Customer.io SDK for Android.
The SDK supports both Kotlin and Java.
To get started, you need to install and initialize the relevant SDK packages in your project. We've separated our SDK into packages to minimize our impact on your app's size. You should only install the packages that you need for your project.
Tip: Check out our sample android app, Remote Habits, for a example of how to use our SDK.
Before you add Customer.io dependencies, update your repositories in the settings.gradle file to include mavenCentral()
:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
}
}
Or if you're using an earlier project setup, in your root level build.gradle
file, make sure that you have mavenCentral()
added as a repository:
allprojects {
repositories {
google()
mavenCentral()
}
}
We separated our SDK into packages to minimize our impact on your app's size. You should only install the packages that you need for your project.
Package | Required? | Description |
---|---|---|
tracking |
Yes | identify people/devices and send events (to trigger campaigns, track metrics, etc). |
messaging-push-fcm |
No | Push and rich push notifications using Google Firebase Cloud Messaging (FCM). |
implementation 'io.customer.android:tracking:<version-here>'
implementation 'io.customer.android:messaging-push-fcm:<version-here>'
Replace version-here
with the the latest version:
Before you can use the Customer.io SDK, you need to initialize it. CustomerIO
is a singleton: once created it will be re-used, until you decide to reconfigure and recreate the instance.
class App : Application() {
override fun onCreate() {
super.onCreate()
val customerIO = CustomerIO.Builder(
siteId = "your-site-id",
apiKey = "your-api-key",
appContext = this
).build()
}
}
The Builder
for CustomerIO exposes configuration options for features such region
,timeout
.
val builder = CustomerIO.Builder(
siteId = "YOUR-SITE-ID",
apiKey = "YOUR-API-KEY",
appContext = this
)
builder.setRegion(Region.EU)
// set the request timeout for all the API requests sent from SDK
builder.setRequestTimeout(8000L)
builder.build()
A best practice is to initialize CustomerIO in the Application class, this way you will be able to access that instance from any part of your application using the instance() method.
See our complete SDK documentation at https://customer.io/docs/sdk/android/
Thanks for taking an interest in our project! We welcome your contributions. Check out our development instructions to get your environment set up and start contributing.
Note: We value an open, welcoming, diverse, inclusive, and healthy community for this project. We expect all contributors to follow our code of conduct.