appsflyer_sdk

A Flutter plugin for AppsFlyer SDK.

pub package Build Status

Getting Started

For help getting started with Flutter, view our online documentation.

For help on editing plugin code, view the documentation.


Supported Platforms

  • Android
  • iOS 8+

This plugin is built for

  • iOS AppsFlyerSDK v4.8.10
  • Android AppsFlyerSDK v4.8.18

## API Methods


AppsflyerSdk(Map options)
parametertypedescription
optionsMapSDK configuration

options

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

Example:

import 'package:appsflyer_sdk/appsflyer_sdk.dart';
//..

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

AppsflyerSdk appsflyerSdk = AppsflyerSdk(appsFlyerOptions);

static Future<dynamic> initSdk() async

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

Example:

import 'package:appsflyer_sdk/appsflyer_sdk.dart';
//..

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

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


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.
parametertypedescription
eventNameStringcustom event name, is presented in your dashboard. See the Event list HERE
eventValuesMapevent details

Example:

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()

Example:

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

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",
  "data": "SOME_ERROR_MESSAGE"
}
static Stream<dynamic> registerOnAppOpenAttributionCallback()

Example:

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

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

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

Libraries

appsflyer_constants
appsflyer_sdk

Dart

dart:ui
Built-in types and core primitives for a Flutter application. [...]

Core

dart:async
Support for asynchronous programming, with classes such as Future and Stream. [...]
dart:collection
Classes and utilities that supplement the collection support in dart:core. [...]
dart:convert
Encoders and decoders for converting between different data representations, including JSON and UTF-8. [...]
dart:core
Built-in types, collections, and other core functionality for every Dart program. [...]
dart:developer
Interact with developer tools such as the debugger and inspector. [...]
dart:math
Mathematical constants and functions, plus a random number generator. [...]
dart:typed_data
Lists that efficiently handle fixed sized data (for example, unsigned 8 byte integers) and SIMD numeric types. [...]

VM

dart:io
File, socket, HTTP, and other I/O support for non-web applications. [...]
dart:isolate
Concurrent programming using isolates: independent workers that are similar to threads but don't share memory, communicating only via messages. [...]