npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cordova-plugin-appsflyer-v

v1.0.6

Published

a plugin for appsflyer

Downloads

24

Readme

Cordova AppsFlyer plugin for Android and iOS.

npm version Build Status


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

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.


Table of content

Supported Platforms

  • Android
  • iOS 8+

This plugin is built for

  • iOS AppsFlyerSDK v4.7.11
  • Android AppsFlyerSDK v4.7.4

Installation using CLI:

$ cordova plugin add cordova-plugin-appsflyer-v

or directly from git:

$ cordova plugin add https://github.com/AppsFlyerSDK/cordova-plugin-appsflyer-v.git

Manual installation:

1. Add the following xml to your config.xml in the root directory of your www folder:

<!-- for iOS -->
<feature name="AppsFlyerPlugin">
  <param name="ios-package" value="AppsFlyerPlugin" />
</feature>
<!-- for Android -->
<feature name="AppsFlyerPlugin">
  <param name="android-package" value="com.appsflyer.cordova.plugin.AppsFlyerPlugin" />
</feature>

2. For Android, add the following xml to your AndroidManifest.xml:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

Inside the <aplication> tag, add the following receiver:

<receiver android:exported="true"    android:name="com.appsflyer.MultipleInstallBroadcastReceiver">
    <intent-filter>
        <action android:name="com.android.vending.INSTALL_REFERRER" />
    </intent-filter>
</receiver>

3. Copy appsflyer.js to www/js/plugins and reference it in index.html:

<script type="text/javascript" src="js/plugins/appsflyer.js"></script>

4. Download the source files and copy them to your project.

iOS:

Copy:

  • AppsFlyerPlugin.h
  • AppsFlyerPlugin.m
  • AppsFlyerTracker.h
  • libAppsFlyerLib.a to platforms/ios/<ProjectName>/Plugins
Android:

Copy AppsFlyerPlugin.java to platforms/android/src/com/appsflyer/cordova/plugins (create the folders)

Usage:

1. Set your App_ID (iOS only), Dev_Key and enable AppsFlyer to detect installations, sessions (app opens) and updates.

This is the minimum requirement to start tracking your app installs and is already implemented in this plugin. You MUST modify this call and provide:
-devKey - Your application devKey provided by AppsFlyer. -appId - For iOS only. Your iTunes Application ID.

Add the following lines to your code to be able to initialize tracking with your own AppsFlyer dev key:

for pure Cordova:
document.addEventListener("deviceready", function(){
    
   var options = {
             devKey:  'xxXXXXXxXxXXXXxXXxxxx8'// your AppsFlyer devKey               
           };

    var userAgent = window.navigator.userAgent.toLowerCase();
                          
    if (/iphone|ipad|ipod/.test( userAgent )) {
        options.appId = "123456789";            // your ios app id in app store        
    }
    window.plugins.appsFlyer.initSdk(options);
}, false);
For Ionic 1
  $ionicPlatform.ready(function() {      
    
    var options = {
           devKey:  'xxXXXXXxXxXXXXxXXxxxx8'// your AppsFlyer devKey               
         };
                              
    if (ionic.Platform.isIOS()) {
        options.appId = "123456789";            // your ios app id in app store 
    }

      window.plugins.appsFlyer.initSdk(options);      
  });

## API Methods


initSdk(options, onSuccess, onError): void

initialize the SDK.

| parameter | type | description | | ----------- |-----------------------------|--------------| | options | Object | SDK configuration | | onSuccess | (message: string)=>void | Success callback - called after successfull SDK initialization. (optional)| | onError | (message: string)=>void | Error callback - called when error occurs during initialization. (optional)|

options

| name | type | default | description | | -----------|---------|---------|------------------------| | devKey |string | | Appsflyer Dev key | | appId |string | | Apple Application ID (for iOS only) | | isDebug |boolean| false | debug mode (optional)| | onInstallConversionDataListener |boolean| false | Accessing AppsFlyer Attribution / Conversion Data from the SDK (Deferred Deeplinking). Read more: Android, iOS. AppsFlyer plugin will return attribution data in onSuccess callback.

Example:

var onSuccess = function(result) {
     //handle result
};

function onError(err) {
    // handle error
}
var options = {
               devKey:  'd3Ac9qPardVYZxfWmCspwL',
               appId: '123456789',
               isDebug: false,
               onInstallConversionDataListener: true
             };
window.plugins.appsFlyer.initSdk(options, onSuccess, onError);

trackEvent(eventName, eventValues): void (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.

| parameter | type | description | | ----------- |-----------------------------|--------------| | eventName | String | custom event name, is presented in your dashboard. See the Event list HERE | | eventValue | Object | event details |

Example:

var eventName = "af_add_to_cart";
var eventValues = {
           "af_content_id": "id123",
           "af_currency":"USD",
           "af_revenue": "2"
           };
window.plugins.appsFlyer.trackEvent(eventName, eventValues);

setCurrencyCode(currencyId): void

| parameter | type | Default | description | | ----------- |-----------------------|-------------|-------------| | currencyId| String | USD | ISO 4217 Currency Codes |

Examples:

window.plugins.appsFlyer.setCurrencyCode("USD");
window.plugins.appsFlyer.setCurrencyCode("GBP"); // British Pound

setAppUserId(customerUserId): void

Setting your own Custom ID enables you to cross-reference your own unique ID with AppsFlyer’s user ID and the other devices’ IDs. This ID is available in AppsFlyer CSV reports along with postbacks APIs for cross-referencing with you internal IDs.

Note: The ID must be set during the first launch of the app at the SDK initialization. The best practice is to call this API during the deviceready event, where possible.

| parameter | type | description | | ----------- |-----------------------------|--------------| | customerUserId | String | |

Example:

window.plugins.appsFlyer.setAppUserId(userId);

setGCMProjectID(GCMProjectNumber): void

AppsFlyer requires a Google Project Number to enable uninstall tracking. More Information

| parameter | type | description | | ----------- |-----------------------------|--------------| | GCMProjectNumber | String | |

enableUninstallTracking(token, onSuccess, onError): void

Enables app uninstall tracking. More Information

| parameter | type | description | | ----------- |-----------------------------|--------------| | token | String | | | onSuccess | (message: string)=>void | Success callback - called after successfull register uninstall. (optional)| | onError | (message: string)=>void | Error callback - called when error occurs during register uninstall. (optional)|


getAppsFlyerUID(successCB): void (Advanced)

Get AppsFlyer’s proprietary Device ID. The AppsFlyer Device ID is the main ID used by AppsFlyer in Reports and APIs.

function getUserIdCallbackFn(id){/* ... */} 
window.plugins.appsFlyer.getAppsFlyerUID(getUserIdCallbackFn);

Example:

var getUserIdCallbackFn = function(id) {
    alert('received id is: ' + id);
}
window.plugins.appsFlyer.getAppsFlyerUID(getUserIdCallbackFn);

| parameter | type | description | | ----------- |-----------------------------|--------------| | getUserIdCallbackFn | () => void | Success callback |


Deep linking Tracking

Android

In ver. >4.2.5 deeplinking metadata (scheme/host) is sent automatically

iOS URL Types

Add the following lines to your code to be able to track deeplinks with AppsFlyer attribution data:

for pure Cordova - add a function 'handleOpenUrl' to your root, and call our SDK as shown:

    window.plugins.appsFlyer.handleOpenUrl(url);

It appears as follows:

var handleOpenURL = function(url) {
    window.plugins.appsFlyer.handleOpenUrl(url);
}

Universal Links in iOS

To enable Universal Links in iOS please follow the guide here.

Note: Our plugin utilizes the

- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray * _Nullable))restorationHandler;

method for Universal Links support.
If additional instances of the method exist in your code - merge all calls into one
(Available on cordova-plugin-appsflyer-v 4.2.24 and higher )

Demo

This plugin has a examples folder with demoA (Angular 1) and demoC (Cordova) projects bundled with it. To give it a try , clone this repo and from root a.e. cordova-plugin-appsflyer-v execute the following:

For Cordova:

npm run setup_c 
  • npm run demo_c.ra - runs Android
  • npm run demo_c.ba - builds Android
  • npm run demo_c.ri - runs iOS
  • npm run demo_c.bi - builds iOS

For Angular:

npm run setup_a
  • npm run demo_a.ra - runs Android
  • npm run demo_a.ba - builds Android
  • npm run demo_a.ri - runs iOS
  • npm run demo_a.bi - builds iOS

demo printscreen