appsflyer_sdk 1.1.0

  • Example
  • Installing
  • Versions
  • 85

appsflyer_sdk #

A Flutter plugin for AppsFlyer SDK.

pub package Build Status

In order for us to provide optimal support, we would kindly ask you to submit any issues to

When submitting an issue please specify your AppsFlyer sign-up (account) email , your app ID , production steps, logs, code snippets and any additional relevant information.

Supported Platforms #

  • Android
  • iOS 8+

This plugin is built for #

  • iOS AppsFlyerSDK v4.8.12
  • Android AppsFlyerSDK v4.8.20

##<a id="api-methods"> API Methods

Getting started #

In order to install the plugin, visit this page.

To start using AppsFlyer you first need to create an instance of AppsflyerSdk before using any other of our sdk functionalities.

AppsflyerSdk(Map options) #
optionsMapSDK configuration


afDevKeystringAppsflyer Dev key
afAppIdstringApple Application ID (for iOS only)
isDebugbooleanfalsedebug mode (optional)


import 'package:appsflyer_sdk/appsflyer_sdk.dart';

Map options = { "afDevKey": afDevKey,
                "afAppId": appId,
                "isDebug": true};

AppsflyerSdk appsflyerSdk = AppsflyerSdk(appsFlyerOptions);

Or you can use AppsFlyerOptions class instead

AppsflyerSdk(Map options) #
optionsAppsFlyerOptionsSDK configuration


import 'package:appsflyer_sdk/appsflyer_sdk.dart';

final AppsFlyerOptions options = AppsFlyerOptions(afDevKey: "af dev key",
                                                  showDebug: true,
                                                  appId: "123456789");

Once AppsflyerSdk object is created, you can call initSdk method.

static Future<dynamic> initSdk() async #

initialize the SDK, using the options initialized from the constructor|


import 'package:appsflyer_sdk/appsflyer_sdk.dart';

AppsflyerSdk appsflyerSdk = AppsflyerSdk({...});

try {
      result = await appsflyerSdk.initSdk();
    } on Exception catch (e) {
      print("error: " + e.toString());

static Future<bool> trackEvent(String eventName, Map eventValues) async (optional)
  • These in-app events help you track how loyal users discover your app, and attribute them to specific campaigns/media-sources. Please take the time define the event/s you want to measure to allow you to track ROI (Return on Investment) and LTV (Lifetime Value).
  • The trackEvent method allows you to send in-app events to AppsFlyer analytics. This method allows you to add events dynamically by adding them directly to the application code.
eventNameStringcustom event name, is presented in your dashboard. See the Event list HERE
eventValuesMapevent details


Future<bool> sendEvent(String eventName, Map eventValues) async {
    bool result;
    try {
      result = await appsflyerSdk.trackEvent(eventName, eventValues);
    } on Exception catch (e) {}
      print("Result trackEvent: ${result}");

Conversion Data and on app open attribution #

Returns Stream. Accessing AppsFlyer Attribution / Conversion Data from the SDK (Deferred Deeplinking). Read more: Android, iOS. AppsFlyer plugin will return attribution data as JSON Map in Stream.

static Stream<dynamic> registerConversionDataCallback() #


appsflyerSdk.registerConversionDataCallback().listen((data) {
      //print("GCD: " + data.toString());
    }).onError((handleError) {

Example of success Organic response:

  "status": "success",
  "type": "onInstallConversionDataLoaded",
  "data": {
    "af_status": "Organic",
    "af_message": "organic install",
    "is_first_launch": "false"

Example of failure response:

  "status": "failure",
  "type": "onInstallConversionDataLoaded",

In case you want to use deep links in your app, you will need to use registerOnAppOpenAttributionCallback on the AppsflyerSdk instance you've created.

static Stream<dynamic> registerOnAppOpenAttributionCallback() #


appsflyerSdk.registerOnAppOpenAttributionCallback().listen((data) {
      //print("OnAppOpenAttribution: " + data.toString());
    }).onError((handleError) {

Example of response on deep-link "https://flutter.demo" :

  "status": "success",
  "type": "onAppOpenAttribution",
  "data": {
    "link": "https://flutter.demo"

Other functionalities: #

void setUserEmails(List<String> emails, [EmailCryptType cryptType] Set the user emails with the given encryption (EmailCryptTypeNone, EmailCryptTypeSHA1, EmailCryptTypeMD5, EmailCryptTypeSHA256). the default encryption is EmailCryptTypeNone. Example:

       ["", ""], EmailCryptType.EmailCryptTypeSHA1);

void setMinTimeBetweenSessions(int seconds) You can set the minimum time between session (the default is 5 seconds)


void stopTracking(bool isTrackingStopped) You can stop sending events to Appsflyer by using this method. Example:


void setCurrencyCode(String currencyCode) Example:


void setIsUpdate(bool isUpdate) Example:


void enableUninstallTracking(String senderId) Example:


void setImeiData(String imei) Example:


void setAndroidIdData(String androidIdData) Example:


void enableLocationCollection(bool flag) Example:


void setCustomerUserId(String userId) What is customer user id? Example:


void waitForCustomerUserId(bool wait) You can set this function to true if you don't want to track events without setting customer id first. Example:


void setAdditionalData(Map addionalData) Example:

appsFlyerSdk.setAdditionalData({"customData": "data"});

void setCollectAndroidId(bool isCollect) Example:


void setCollectIMEI(bool isCollect) Example:


void setHost(String hostPrefix, String hostName) You can change the default host (appsflyer) by using this function Example:

appsFlyerSdk.setHost("pref", "my-host");

Future<String> getHostName() Example:

appsFlyerSdk.getHostName().then((name) {
         print("Host name: ${name}");

Future<String> getHostPrefix() Example:

appsFlyerSdk.getHostPrefix().then((name) {
         print("Host prefix: ${name}");

void updateServerUninstallToken(String token) Example:


Stream validateAndTrackInAppPurchase( String publicKey, String signature, String purchaseData, String price, String currency, Map<String, String> additionalParameters) Example:

           {"fs": "fs"}).listen((data) {
       }).onError((error) {

Versions #

1.1.0 #

  • Added the following functions:

    • Stream validateAndTrackInAppPurchase( String publicKey, String signature, String purchaseData, String price, String currency, Map<String, String> additionalParameters)
    • void updateServerUninstallToken(String token)
    • Future<String> getHostPrefix()
    • Future<String> getHostName()
    • void setHost(String hostPrefix, String hostName)
    • void setCollectIMEI(bool isCollect)
    • void setCollectAndroidId(bool isCollect)
    • void setAdditionalData(Map addionalData)
    • void waitForCustomerUserId(bool wait)
    • void setCustomerUserId(String userId)
    • void enableLocationCollection(bool flag)
    • void setAndroidIdData(String androidIdData)
    • void setImeiData(String imei)
    • void enableUninstallTracking(String senderId)
    • void setIsUpdate(bool isUpdate)
    • void setCurrencyCode(String currencyCode)
    • void stopTracking(bool isTrackingStopped)
    • void setMinTimeBetweenSessions(int seconds)
    • void setUserEmails(List<String> emails, [EmailCryptType cryptType]
  • Fixed onAppOpenAttribution not being called bug

1.0.8 #

  • Added AppsFlyerOptions to support easier options setup
  • Changed plugin lib structure

1.0.6 #

  • Fixed iOS app id crash

1.0.4 #

  • Added dartdoc documentation.
  • Changed static methods to class instance methods.

1.0.0 #

First stable version

0.0.5 #

  • Changed access modifiers from public to private to class variables

0.0.3 #

Supported sdk functions:

  • initSdk
  • trackEvent
  • registerConversionDataCallback
  • registerOnAppOpenAttributionCallback

0.0.1 #

Initial release.


appsflyer_sdk_example #

This plugin has a demo project bundled with it. To give it a try , clone this repo and from root a.e. flutter_appsflyer_sdk execute the following:

$ flutter packages get
$ cd example/
$ flutter run

demo printscreen

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  appsflyer_sdk: ^1.1.0

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter packages get

Alternatively, your editor might support flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:appsflyer_sdk/appsflyer_sdk.dart';
Version Uploaded Documentation Archive
1.1.0 Feb 14, 2019 Go to the documentation of appsflyer_sdk 1.1.0 Download appsflyer_sdk 1.1.0 archive
1.0.8 Feb 3, 2019 Go to the documentation of appsflyer_sdk 1.0.8 Download appsflyer_sdk 1.0.8 archive
1.0.7 Jan 16, 2019 Go to the documentation of appsflyer_sdk 1.0.7 Download appsflyer_sdk 1.0.7 archive
1.0.6 Jan 8, 2019 Go to the documentation of appsflyer_sdk 1.0.6 Download appsflyer_sdk 1.0.6 archive
1.0.5 Dec 31, 2018 Go to the documentation of appsflyer_sdk 1.0.5 Download appsflyer_sdk 1.0.5 archive
1.0.4 Dec 31, 2018 Go to the documentation of appsflyer_sdk 1.0.4 Download appsflyer_sdk 1.0.4 archive
1.0.3 Dec 30, 2018 Go to the documentation of appsflyer_sdk 1.0.3 Download appsflyer_sdk 1.0.3 archive
1.0.2 Dec 27, 2018 Go to the documentation of appsflyer_sdk 1.0.2 Download appsflyer_sdk 1.0.2 archive
1.0.1 Dec 26, 2018 Go to the documentation of appsflyer_sdk 1.0.1 Download appsflyer_sdk 1.0.1 archive
1.0.0 Dec 26, 2018 Go to the documentation of appsflyer_sdk 1.0.0 Download appsflyer_sdk 1.0.0 archive

All 15 versions...

Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Mar 6, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.2.0
  • pana: 0.12.14
  • Flutter: 1.3.3


Detected platforms: Flutter

References Flutter, and has no conflicting libraries.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.68.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11
meta 1.1.6 1.1.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
mockito 3.0.0
test ^1.3.0