
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-plugin-appsflyer-sdk
Advanced tools
$ cordova plugin add cordova-plugin-appsflyer-sdk
or directly from git:
$ cordova plugin add https://github.com/AppsFlyerSDK/cordova-plugin-appsflyer-sdk.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" />
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.
Copy:
AppsFlyerPlugin.h
AppsFlyerPlugin.m
AppsFlyerTracker.h
libAppsFlyerLib.a
to platforms/ios/<ProjectName>/Plugins
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 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:
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);
$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);
});
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)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 |
registerUninstall(token): void
Enables app uninstall tracking. More Information
parameter | type | description |
---|---|---|
token | String |
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 |
In ver. >4.2.5 deeplinking metadata (scheme/host) is sent automatically
Open in Xcode AppDelegate.m
, add #import "AppsFlyerTracker.h"
and add the following method under application: openURL
:
[[AppsFlyerTracker sharedTracker] handleOpenURL:url sourceApplication:sourceApplication withAnnotation:annotation];
It appears as follows:
-(BOOL) application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
[[AppsFlyerTracker sharedTracker] handleOpenURL:url sourceApplication:sourceApplication withAnnotation:annotation];
return YES;
}
##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-sdk
execute the following:
For Cordova:
npm run setup_c
npm run demo_c.ra
- runs Androidnpm run demo_c.ba
- builds Androidnpm run demo_c.ri
- runs iOSnpm run demo_c.bi
- builds iOSFor Angular:
npm run setup_a
npm run demo_a.ra
- runs Androidnpm run demo_a.ba
- builds Androidnpm run demo_a.ri
- runs iOSnpm run demo_a.bi
- builds iOSFAQs
Cordova AppsFlyer SDK Plugin
The npm package cordova-plugin-appsflyer-sdk receives a total of 2,067 weekly downloads. As such, cordova-plugin-appsflyer-sdk popularity was classified as popular.
We found that cordova-plugin-appsflyer-sdk demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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.