Quick Start Guide

Updated

Before you can take advantage of our SDK, you need to install and initialize the SDK. This page also explains how the SDK prioritizes operations.

1. Set up your development environment

Before you get started, you need to do the following things to support iOS and Android respectively:

  1. Add your Google Firebase Cloud Messaging (FCM) key to Customer.io and enable push notifications for Android. Our Flutter SDK receives push notifications from FCM.
  2. Set up your iOS environment:
    1. Set up XCode and set your deployment target to 13.0 or later.
    2. Make sure that you have XCode command line tools installed xcode-select --install.
    3. Have an iOS 13 device to test with. You cannot test push notifications in an emulator.
  3. Set up your Android environment:
    1. Download and install Android Studio.
    2. Make sure you use an appropriate version of the Android Gradle plugin.
    3. Have an Android device or emulator with Google Play Services enabled and a minimum OS version.

2. Create a Flutter source

Before you can integrate your app, you need to tell Customer.io that you have a Flutter 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: Flutter source and then click Next: Connect Flutter.
    set up your Flutter source
    set up your Flutter source
  3. Enter a Name for the source, like “My Flutter 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. Test your connect and click Complete Setup. Or, if you don’t want to test your implementation yet, Save & Complete Later and then click Install Source to finish the setup process. In this case, Complete Later simply means that we haven’t seen any data from your Flutter app yet.
    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 Flutter source is connected to your Journeys workspace. Hover over a source or destination to see its active connections. You can also connect your Flutter 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 Flutter source connected to a journeys destination
the connections page, showing an Flutter source connected to a journeys destination

3. Install the Flutter SDK

This process involves setup for both iOS and Android. For Android, the directions below will guide you through the setup process for both Firebase Cloud Messaging (FCM) and our in-app messaging module; both are required to use the Flutter SDK.

 Want to update to the latest version of the Customer.io Flutter SDK? See our update guide.

  1. Open your terminal and go to your project folder: cd <Root/path/to/your/app>

  2. Add our Flutter SDK package from the command line.

    flutter pub add customer_io
    

    This adds a line to your package’s pubspec.yaml

    dependencies:
       customer_io: ^2.1.1
    
  3. In your terminal, run pod install --repo-update --project-directory=ios. This adds the required iOS dependencies to your project. When the process is complete, you’ll see a message like this:

    Pod installation complete! There are X dependencies from the Podfile and Y total pods installed.

  4. Make sure that your minimum deployment target is set to 13.0. You’ll have to do this in two places:

    1. Go to the ios subfolder and open your Podfile. Find the platform:ios line, and make sure that the version is set to 13.0 or later if it isn’t already.

    2. Open your project’s iOS directory in XCode, select the project under Targets, and set the Minimum Deployments target to 13.0 or later.

      Set your iOS deployment target
      Set your iOS deployment target
  5. Go to the Android subfolder and include google-services-plugin by adding the following lines to the project-level android/build.gradle file:

    buildscript {
       repositories {
          // Add this line if it isn't already in your build file:
          google()  // Google's Maven repository
       }
    
       dependencies {
          // Add this line:
          classpath 'com.google.gms:google-services:<version-here>'  // Google Services plugin
       }
    }
    
    allprojects {
       repositories {
          // Add this line if it isn't already in your build file:
          google()  // Google's Maven repository
       }
    }
    
  6. Add the following line to android/app/build.gradle:

    apply plugin: 'com.google.gms.google-services'  // Google Services plugin
    
  7. Download google-services.json from your Firebase project and copy the file to android/app/google-services.json.

Now you’re ready to initialize the SDK and use it in your app.

4. Initialize and configure the SDK

After you install the SDK, you’ll need to configure and initialize it in your app. In your main.dart file—or wherever you want to initialize the CustomerIO plugin—add the code below.

You’ll need:

  1. Your cdpApiKey from the Flutter sourceA source is a website or server that you want to capture data from—it’s a source of data! you setup in previous steps.
  2. Your siteId which you can find in Customer.io under Settings > Workspace Settings > API Credentials. This value supports in-app messaging and acts as a migrationSiteId if you migrate from a previous version of the SDK.

You’ll find a complete list of configuration options on the Packages and Configuration Options page. But our default settings should suffice for most use cases.

import 'package:customer_io/customer_io.dart';
import 'package:customer_io/customer_io_config.dart';
import 'package:customer_io/customer_io_enums.dart';


await CustomerIO.initialize(
   config: CustomerIOConfig(
      cdpApiKey: 'cdpApiKey',
      region: Region.us,
      inAppConfig: InAppConfig(siteId: 'siteId'),
      pushConfig: PushConfig(
      android: PushConfigAndroid(
         pushClickBehavior:
         PushClickBehaviorAndroid.activityPreventRestart,
      ),
      ),
   ),
);

When you’re done, you might want to run your application to make sure everything’s set up correctly. If you don’t get any errors, you’re ready to start using the SDK in your app—set up push notifications, identify people, and so on.

 Check out our code samples!

You’ll find working sample apps in our Flutter SDK’s app directory. If you get stuck, you can refer to the sample apps to see how everything fits together.

Copied to clipboard!
  Contents
Current release
 2.1.1
Is this page helpful?