Adobe AIR plugin

At a glanceThe AppsFlyer Adobe AIR plugin provides app attribution and event reporting functionality to Android and iOS mobile apps developed on the Adobe AIR development platform. The plugin is functionally equivalent to the AppsFlyer iOS and Android SDKs.

Plugin information

Supported platforms:

  • Android
  • iOS 6+

Based on:

  • iOS AppsFlyer SDK V6.0.3
  • Android AppsFlyer SDK V5.4.1

Installation and implementation

Installation

Download the AppsFlyerAIRExtension.ane file from the bin folder Add the ANE to your project and make sure the IDE is marked to package it.

If the following was not added automatically, add it to the APP_NAME-app.xml:

<extensions>
  <extensionID>com.appsflyer.adobeair</extensionID>
</extensions>

 Notes for Android apps

  • On AppsFlyer's dashboard you will need to add "air." prefix to the package name as this is added automatically by Air. For example - an app with the package name "com.test.android" , should set the app id on AppsFlyer's Dashboard as "air.com.test.android".

  • Add the following permissions to Android Manifest (in the app description APP_NAME-app.xml):

    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
    <uses-permission android:name="com.google.android.finsky.permission.BIND_GET_INSTALL_REFERRER_SERVICE" />
    
  • Add the following metatag to Android Manifest within the application tag (in the app description APP_NAME-app.xml):

    meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />

As a result, you should see your Manifest like this:

Important: Due to some limitations in the ADT, after the APK is built, it is missing some important files.

To add those files (with the help of automated script):

  1. Place into single directory of your choice:
  2. Run ./af_apk_fix.sh and enter requested info when prompted.

Here is what the script is doing. In case of any issues, you can perform those steps manually:

  1. Decode the APK using apktool. This will create app_name folder.
    apktool d app_name.apk

  2. Download the AppsFlyer SDK jar/aar of the same version that was used in the APK.

  3. Extract files a- and b- from the jar (by renaming jar into a zip) and place them into the folder with the decompiled apk to app_name/unknown/com/appsflyer/internal

  4. Edit apktool.yml by adding these lines under unknownFiles: 

    com/appsflyer/internal/b-: '0'
    com/appsflyer/internal/a-: '0'
    


    See sample screenshot that follows.

  5. Build the APK.back (will appear under app_name/dist folder).
    apktool b app

  6. Sign the APK.

    jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore myKeystore.keystore app_name/dist/app_name.apk myKey
  7. Zipalign the apk (to be able to upload to Google Play)

    zipalign -f -v 4 app_name/dist/app_name.apk app_name/dist/zipalign_app_name.apk
  8. Verify zipalignment

    zipalign -c -v 4 app_name/dist/zipalign_app_name.apk
  9. Your apk  zipalign_app_name.apk  is ready to use!

Implementation

Import the AppsFlyer Extension into your project:

import AppsFlyerInterface;

Construct the AppsFlyer interface:

private static var appsFlyer:AppsFlyerInterface; 
appsFlyer = new AppsFlyerInterface();

[Optional] If you want to perform deep linking or access AppsFlyer conversion data from the application, register Conversion Listener:

appsFlyer.registerConversionListener();

Set the Developer key and iOS app ID (optional) and Initialise the SDK:

appsFlyer.appsFlyer.init("DevKey", "iOSAppID");

Initialize session logging (automatically log app launches and background-to-foreground transitions) with DevKey and iOS app ID (optional):

appsFlyer.start("DevKey", "iOSAppID");

Deep linking

In order to receive the relevant AppsFlyer information from the deep link used:

  1. Register the following event listeners:
    appsFlyer.addEventListener(AppsFlyerEvent.APP_OPEN_ATTRIBUTION, eventHandler); // success 
    appsFlyer.addEventListener(AppsFlyerEvent.ATTRIBUTION_FAILURE, eventHandler); // error 
    
  2. Handle the response in a corresponding event handler:
    private function eventHandler(event:AppsFlyerEvent):void {
    	log("AppsFlyer event: " + event.type + "; \nData: " + event.data);
    }

Deferred deep linking

In order to receive the conversion data for the current install:

  1. Register the following event listeners:
    appsFlyer.addEventListener(AppsFlyerEvent.INSTALL_CONVERSATION_DATA_LOADED, eventHandler); // success
    appsFlyer.addEventListener(AppsFlyerEvent.INSTALL_CONVERSATION_FAILED, eventHandler); //error
    
  2. Handle the response in a corresponding event handler:
    private function eventHandler(event:AppsFlyerEvent):void {
    	log("AppsFlyer event: " + event.type + "; \nData: " + event.data);
    }

IMEI and Android ID collection (Android only)

Important! Apps with Google play services should avoid IMEI collection as this is in violation of the Google Play policy.

By default, IMEI and Android ID are not collected by the SDK if the OS version is higher than KitKat (4.4) and the device contains Google Play Services.

To explicitly send these IDs to AppsFlyer, developers can use the following APIs and place them before initializing the SDK.

If the app does NOT contain Google Play Services, the IMEI and Android ID are collected by the SDK.

Enable/disable IMEI collection (disabled by default)

appsFlyer.setCollectIMEI(bool);

Manually set IMEI Data

appsFlyer.setImeiData("imeiString");

Enable/disable Android ID collection (disabled by default)

appsFlyer.setCollectAndroidID(bool);

Manually set Android ID data

appsFlyer.setAndroidIdData("AndroidIDString");

API reference

API methods
Name Description Signature/example

logEvent

Log in-app events.
var param:String = "Deposit";
var value:String = '{"amount":10, "FTDLevel":"-"}';
appsFlyer.logEvent(param, value);
start

Send a session logging event, regardless of app state.

appsFlyer.start();
 setAppUserId

Get the user ID as used in the app. 

appsFlyer.setAppUserId("user_id_as_used_in_the_app");
 setUserEmails

Get user email.

appsFlyer.setUserEmails("example@example.com");
 setCurrency

Set the currency for logging revenue events, for example, USD.

appsFlyer.setCurrency("USD");
 stop

Used when you want want to shut down all SDK logging due to legal and privacy compliance. Once this API is invoked, our SDK no longer communicates with our servers.

appsFlyer.stop();
 setDebug

Enable/disable AppsFlyer debug logs.

Important: Do not release the app to app stores with debug logs enabled.

appsFlyer.setDebug(bool);
Was this article helpful?