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

mp.plugins.appsflyer

v1.3.0

Published

Register and receive push notifications.

Downloads

5

Readme

PhoneGap AppsFlyer plugin for Android and iOS.

Built against Phonegap >= 3.3.x.

PhoneGap Build

Add the following line to your config xml:

<gap:plugin name="com.appsflyer.phonegap.plugins.appsflyer" version="1.0.1" />

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

document.addEventListener("deviceready", function(){
    var args = [];
    var devKey = "xxXXXXXxXxXXXXxXXxxxx8";   // your AppsFlyer devKey
    args.push(devKey);
    var userAgent = window.navigator.userAgent.toLowerCase();
                          
    if (/iphone|ipad|ipod/.test( userAgent )) {
        var appId = "123456789";            // your ios app id in app store
        args.push(appId);
    }
	window.plugins.appsFlyer.initSdk(args);
}, false);

Installation using CLI:

$ cordova plugin add https://github.com/AppsFlyerSDK/PhoneGap.git

Then reference appsflyer.js in index.html, after cordova.js/phonegap.js. Mind the path:

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

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" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />

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 and 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.

**Note: ** *This is the minimum requirement to start tracking your app installs and it's 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.
document.addEventListener("deviceready", function(){
    var args = [];
    var devKey = "xxXXXXXxXxXXXXxXXxxxx8";   // your AppsFlyer devKey
    args.push(devKey);
    var userAgent = window.navigator.userAgent.toLowerCase();
                          
    if (/iphone|ipad|ipod/.test( userAgent )) {
        var appId = "123456789";            // your ios app id in app store
        args.push(appId);
    }
	window.plugins.appsFlyer.initSdk(args);
}, false);

2. Set currency code (optional)

//USD is default value. Acceptable ISO(http://www.xe.com/iso4217.php) Currency codes here. Examples:  
//British Pound: window.plugins.appsFlyer.setCurrencyCode("GBP");  
window.plugins.appsFlyer.setCurrencyCode("USD");

3. Set customer user ID (Advance)

Setting your own custom ID will enable you to cross-reference your own unique ID with AppsFlyer’s user ID and the other devices’ IDs. This ID will be available at 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 to this API during deviceready event if possible.

window.plugins.appsFlyer.setAppUserId(userId);

4. In App Events Tracking API (optional)

These events help you track how loyal users discover your app and attribute them to specific campaign/source.

  • 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 would like 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.
// eventName - any string to define the event name. For example: “registration” or “purchase”
// eventValue - the sales value. For example: 0.99 or 0.79
window.plugins.appsFlyer.sendTrackingWithEvent(eventName, eventValue);
// window.plugins.appsFlyer.sendTrackingWithEvent(eventName, "");

5. Get AppsFlyer’s Unique Device UID (Advanced)

Get AppsFlyer’s proprietary device ID. AppsFlyer device ID is the main ID used by AppsFlyer in the Reports and API’s.

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

6. Accessing AppsFlyer Attribution / Conversion Data from the SDK (Deferred

Deep-linking). Read more: Android, iOS
Note: AppsFlyer plugin will fire onInstallConversionDataLoaded event with attribution data. You must implement listener to receive the data.

Example:
document.addEventListener('onInstallConversionDataLoaded', function(e){
	var attributionData = (JSON.stringify(e.detail));
	alert(attributionData);
}, false);