Quick Start Guide

Updated

Before you can take advantage of our SDK, you need to install the module(s) you want to use, initialize the SDK, and understand the order of operations.

Prerequisites

Before you start, you’ll need two keys. See Authentication you don’t have them, or don’t know where to find them.

1. Create an Android Source

Before you can integrate your app, you need to tell Customer.io that you have an Android app. This is what we call a sourceA source is a website or server that you want to capture data from—it’s a source of data!.

Your source provides the API key you’ll use to initialize the SDK.

  1. Go to the Data Pipelines tab. On the Connections page under Sources, click Add Source.
  2. Select the Mobile: Android source and then click Next: Connect Android.
    set up your android source
    set up your android source
  3. Enter a Name for the source, like “My Android App”.
  4. We’ll present you with a code sample containing a cdpApiKey that you’ll use to initialize the SDK. Copy this key and keep it handy.
  5. Click Complete Setup to finish setting up your source.
    Set your name, get your CDP API Key, and click Complete Setup
    Set your name, get your CDP API Key, and click Complete Setup

Now the Connections page shows that your Android source is connected to your Journeys workspace. Hover over a source or destination to see its active connections. You can also connect your Android source to additional destinations if you want to send your mobile data to additional services—like your analytics provider, data warehouse, or CRM.

the connections page, showing an android source connected to a journeys destination
the connections page, showing an android source connected to a journeys destination

2. Install and Initialize the SDK

Use the instructions below to install and initialize the SDK. We’ve based the code samples for these steps on sample apps in our Android SDK repository. Check out the samples directory to see complete working examples for both Kotlin and Java.

  1. Before you add Customer.io dependencies, update your repositories in your build.gradle or settings.gradle file.
    android {
      repositories {
        google()
        mavenCentral()
      }
      ...
    }
  2. Add Customer.io packages as dependencies in your build.gradle file.
    dependencies {
      implementation "io.customer.android:datapipelines:4.2.0"
      implementation "io.customer.android:messaging-push-fcm:4.2.0"
      implementation "io.customer.android:messaging-in-app:4.2.0"
    }
    1. Initialize the CustomerIOBuilder in your Application class, so you can access it from any part of your application using the instance() method. Within the builder, you can add and configure modules.

      If you’re in our EU region, make sure that you set Region.EU.

    2. (Optional) Add and configure the MessagingInApp module. You’ll need your Site ID. This tells the SDK which Customer.io workspace your messages come from.
    3. (Optional) Add the MessagingPushFCM module to send push notifications.
    class MainApplication : Application() {
    
        @Inject
        lateinit var preferences: PreferenceRepository
    
        override fun onCreate() {
            super.onCreate()
    
            // Step 3
            CustomerIOBuilder(
                applicationContext = this,
                cdpApiKey = "your_cdp_api_key"
            ).apply {
                // If you're in the EU, set Region.EU
                Region.US
    
                // Step 4: optional, support in-app messages
                // Again, if you're in the EU, set Region.EU
                addCustomerIOModule(
                    ModuleMessagingInApp(
                        config = MessagingInAppModuleConfig.Builder(
                            siteId = "your_site_id",
                            region = Region.US
                        ).setEventListener(InAppMessageEventListener()).build()
                    )
                )
    
                // Step 5: optional, support push notifications
                addCustomerIOModule(ModuleMessagingPushFCM())
                build()
            }
        }
    }
  3. Add a way to identify people. While we support anonymous events, most of Customer.io’s features rely on identified people.

    We’ve provided an example from our sample apps. You’ll find our sample apps in the SDK’s /samples directory. They can help you better understand how to implement our SDK.

      private fun login(
          email: String,
          name: String,
          isGuest: Boolean = false,
          onLoginSuccess: () -> Unit
      ) {
          viewModelScope.launch(Dispatchers.IO) {
              userRepository.login(email = email, name = name, isGuest = isGuest)
              CustomerIO.instance().identify(
                  userId = email,
                  traits = mapOf("name" to name, "is_guest" to isGuest)
              )
              CustomerIO.instance().track(
                  name = "login",
                  properties = mapOf("name" to name, "email" to email)
              )
              withContext(Dispatchers.Main) {
                  onLoginSuccess.invoke()
              }
          }
      }
Copied to clipboard!
  Contents
Current release
 4.2.0
Is this page helpful?