Quick Start Guide
UpdatedBefore 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:
- 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.
- Set up your iOS environment:
- Set up XCode and set your deployment target to 13.0 or later.
- Make sure that you have XCode command line tools installed
xcode-select --install
. - Have an iOS 13 device to test with. You cannot test push notifications in an emulator.
- Set up your Android environment:
- Download and install Android Studio.
- Make sure you use an appropriate version of the Android Gradle plugin.
- 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.
- Go to the Data Pipelines tab. On the Connections page under Sources, click Add Source.
- Select the Mobile: Flutter source and then click Next: Connect Flutter.
- Enter a Name for the source, like “My Flutter App”.
- 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. - 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.
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.
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.
Open your terminal and go to your project folder:
cd <Root/path/to/your/app>
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
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.
Make sure that your minimum deployment target is set to
13.0
. You’ll have to do this in two places: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 } }
Add the following line to
android/app/build.gradle
:apply plugin: 'com.google.gms.google-services' // Google Services plugin
Download
google-services.json
from your Firebase project and copy the file toandroid/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:
- 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. - Your
siteId
which you can find in Customer.io under Settings > Workspace Settings > API Credentials. This value supports in-app messaging and acts as amigrationSiteId
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.