NativeScript Plugin

  • Advertisers
  • Developers

You can also find this plugin on npm here:

https://www.npmjs.com/package/nativescript-plugin-appsflyer

Set out below are the integration instructions for using AppsFlyer’s React Plugin.

This plugin is built for:

  • iOS AppsFlyerSDK v4.5.9
  • Android AppsFlyerSDK v4.6.0

Follow these steps for the installation instructions for the AppsFlyer plugin:

First, download the library from npm:

$ tns plugin add nativescript-plugin-appsflyer

Call module by adding (native javascript):

var appsFlyer = require("nativescript-plugin-appsflyer");

appsFlyer.initSdk(options, callback): void

Initializes the SDK.

parameter type description
options Object SDK configuration

Options

name type default description
devKey string AppsFlyer Dev key
appId string Apple Application ID (for iOS only)
isDebug boolean false debug mode (optional)

Example:

var options = {
devKey: 'WdpTVAcYwmxsaQ4WeTspmh',
appId: "975313579",
isDebug: true
};
appsFlyer.initSdk(options).then(function(result) {
viewModel.set("initSdkResponse", result.status);
}, function(err) {
viewModel.set("initSdkResponse", JSON.stringify(err));
});


appsFlyer.trackEvent(options): Promise<any>

  • 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
options Object track event configuration

options

parameter type description
eventName string custom event name, is presented in your dashboard. See the Event list here
eventValues Object event details (see example bellow)

Example: (native javascript)

var options = {
eventName: "af_add_to_cart",
eventValues: {
"af_content_id": "id123",
"af_currency": "USD",
"af_revenue": "2"
}
};
appsFlyer.trackEvent(options).then(function(result) {
viewModel.set("trackEventResponse", result);
}, function(err) {
viewModel.set("trackEventResponse", JSON.stringify(err));
});
Demo

This plugin has a demo project bundled with it. To give it a try , clone this repo and from root a.e. nativescript-plugin-appsflyer execute the following:

npm run setup
  • Run npm run demo.ios or npm run demo.android will run for the appropriate platform.

Was this article helpful?
1 out of 1 found this helpful