
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Cordova >= 4.3.x.
$ cordova plugin add https://github.com/AppsFlyerSDK/PhoneGap.git
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)
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.
Add 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 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);
For Ionic
$ionicPlatform.ready(function() {
var args = [];
var devKey = "xxXXXXXxXxXXXXxXXxxxx8"; // your AppsFlyer devKey
args.push(devKey);
if (ionic.Platform.isIOS()) {
var appId = "123456789"; // your ios app id in app store
args.push(appId);
}
window.plugins.appsFlyer.initSdk(args);
});
//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");
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);
These events help you track how loyal users discover your app and attribute them to specific campaign/source.
var eventName = "af_add_to_cart";
var eventValues = {"af_content_id": "id123", "af_currency":"USD", "af_revenue": "2"};
window.plugins.appsFlyer.trackEvent(eventName, eventValues);
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);
var getUserIdCallbackFn = function(id) {
alert('received id is: ' + id);
}
window.plugins.appsFlyer.getAppsFlyerUID(getUserIdCallbackFn);
Deep-linking). Read more: Android, iOS
Note: AppsFlyer plugin will fire onInstallConversionDataLoaded
event with attribution data. You must implement listener to receive the data.
document.addEventListener('onInstallConversionDataLoaded', function(e){
var attributionData = (JSON.stringify(e.detail));
alert(attributionData);
}, false);
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 initiation. (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 | true | debug mode (optional) |
Example:
var onSuccess = function(result) {
//handle result
};
function onError(err) {
// handle error
}
var options = {
devKey: 'd3Ac9qPnrpVYZxfWmCspwL',
appId: '123456789',
isDebug: false
};
window.plugins.appsFlyer.initSdk(options, onSuccess, onError);
setCurrencyCode(currencyId): void
parameter | type | description |
---|---|---|
currencyId | String |
setAppUserId(customerUserId): void
set your Customer User ID.
parameter | type | description |
---|---|---|
customerUserId | String |
setGCMProjectID(GCMProjectID): void
Set the GCM API key. AppsFlyer requires a Google Project Number and GCM API Key to enable uninstall tracking.
parameter | type | description |
---|---|---|
GCMProjectID | String |
registerUninstall(token): void
AEnables tracking app. uninstalls.
parameter | type | description |
---|---|---|
token | String |
getAppsFlyerUID(successCB): void
parameter | type | description |
---|---|---|
successCB | () => void | Success callback |
trackEvent(eventName, eventValue): void
Tracking in-app events helps you measure and analyze how loyal users discover your app, and attribute them to specific campaigns/media sources. It is recommended to take the time and define the events you want to measure to allow you to track ROI (Return on Investment) and LTV (Lifetime Value).
parameter | type | description |
---|---|---|
eventName | String | |
eventValue | Object |
onInstallConversionDataLoaded(conversionData): void
parameter | type | description |
---|---|---|
conversionData | Object |
FAQs
Cordova AppsFlyer Plugin
The npm package appsflyer receives a total of 5 weekly downloads. As such, appsflyer popularity was classified as not popular.
We found that appsflyer demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.