CleverTap Flutter SDK

The CleverTap Flutter SDK for Mobile Customer Engagement and Analytics solutions

CleverTap brings together real-time user insights, an advanced segmentation engine, and easy-to-use marketing tools in one mobile marketing platform — giving your team the power to create amazing experiences that deepen customer relationships. Our intelligent mobile marketing platform provides the insights you need to keep users engaged and drive long-term retention and growth.

For more information check out our website and documentation.

Install and Integration

To add the CleverTap Flutter SDK to your project, edit your project's pubspec.yaml file:

    dependencies:
    clevertap_plugin: 1.1.0

Run flutter packages get to install the SDK

Now, in your Dart code, you can use :

    import 'package:clevertap_plugin/clevertap_plugin.dart';

Android

Add the following to your dependencies section in project/build.gradle

    dependencies {
            classpath 'com.android.tools.build:gradle:3.5.1'
            classpath 'com.google.gms:google-services:4.3.2' //<--- Mandatory for using Firebase Messaging, skip if not using FCM
        }

Add the following to your dependencies section in app/build.gradle

    implementation 'com.clevertap.android:clevertap-android-sdk:3.6.4'
        implementation 'com.android.support:support-v4:28.0.0'
        implementation 'com.google.firebase:firebase-messaging:17.3.4'//Mandatory for using FCM push notifications, skip if not using FCM
        implementation 'com.android.support:appcompat-v7:28.0.0'//MANDATORY for App Inbox
        implementation 'com.android.support:design:28.0.0'//MANDATORY for App Inbox
        implementation 'com.github.bumptech.glide:glide:4.9.0'//MANDATORY for App Inbox
    //For CleverTap Android SDK v3.6.4 and above add the following -
        implementation 'com.android.installreferrer:installreferrer:1.0'
    //Optional ExoPlayer Libraries for Audio/Video Inbox Messages. Audio/Video messages will be dropped without these dependencies
        implementation 'com.google.android.exoplayer:exoplayer:2.8.4'
        implementation 'com.google.android.exoplayer:exoplayer-hls:2.8.4'
        implementation 'com.google.android.exoplayer:exoplayer-ui:2.8.4'

At the end of the app/build.gradle file add the following

    apply plugin: 'com.google.gms.google-services' //skip if not using FCM

In your app's Android Application class add the following code.

    public class MyApplication extends FlutterApplication {
        @java.lang.Override
        public void onCreate() {
            ActivityLifecycleCallback.register(this); //<--- Add this before super.onCreate()
            super.onCreate();
        }
    }

If you do not have an Application class, add this to your AndroidManifest.xml

    <application
        android:label="@string/app_name"
        android:icon="@drawable/ic_launcher"
        android:name="com.clevertap.android.sdk.Application"> 

Add the following permissions which are needed by the CleverTap SDK

    <!-- Required to allow the app to send events and user profile information -->
    <uses-permission android:name="android.permission.INTERNET"/>
    <!-- Recommended so that CleverTap knows when to attempt a network call -->
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

Add your CleverTap Account ID and Token to your AndroidManifest.xml, within the tags.

    <meta-data
        android:name="CLEVERTAP_ACCOUNT_ID"
        android:value="Your CleverTap Account ID"/>
    <meta-data
        android:name="CLEVERTAP_TOKEN"
        android:value="Your CleverTap Account Token"/>
    <!-- IMPORTANT: To force use Google AD ID to uniquely identify  users, use the following meta tag. GDPR mandates that if you are using this tag, there is prominent disclousure to your end customer in their application. Read more about GDPR here - https://clevertap.com/blog/in-preparation-of-gdpr-compliance/ -->
    <meta-data
        android:name="CLEVERTAP_USE_GOOGLE_AD_ID"
        android:value="1"/> 

iOS

After install, you will need to integrate the CleverTap SDK into your apps.

  1. Follow the integration instructions starting with Step 2 here.
  2. In your AppDelegate didFinishLaunchingWithOptions: notify the CleverTap Flutter SDK of application launch:
[CleverTap autoIntegrate]; // integrate CleverTap SDK using the autoIntegrate option
[[CleverTapPlugin sharedInstance] applicationDidLaunchWithOptions:launchOptions];

NOTE: Don't forget to add the CleverTap imports at the top of the file.

#import "CleverTap.h"
#import "CleverTapPlugin.h"

Example Dart Usage

Please checkout the example directory for the sample app.

For more:

For more information you can checkout the developer docs

Libraries

clevertap_plugin