Nutritious Polygonal Meatball
Wondering what’s next for npm?Check out our public roadmap! »

cordova-plugin-appsflyer-sdk

6.2.0 • Public • Published

Cordova AppsFlyer plugin for Android and iOS.

npm version Build Status License: MIT Downloads


❗️Important

  • Cordova AppsFlyer plugin version 4.4.0 and higher are meant to be used with cordova-android@7.0.0 and up
    For lower versions of cordova-android please use plugin version 4.3.3 available @ https://github.com/AppsFlyerSDK/cordova-plugin-appsflyer-sdk/tree/4.3.3
  • From version 6.1.10 the plugin uses cocoapods(NOT StaticLib) in order to support iOS app-kids Strict mode.
    You can read more here

🛠 In order for us to provide optimal support, we would kindly ask you to submit any issues to support@appsflyer.com

When submitting an issue please specify your AppsFlyer sign-up (account) email , your app ID , reproduction steps, code snippets, logs, and any additional relevant information.


Table of content

This plugin is built for

  • iOS AppsFlyerSDK v6.1.3
  • Android AppsFlyerSDK v6.1.3

v6 Breaking Changes

We have renamed the following APIs:

Old API New API
trackEvent logEvent
stopTracking Stop
trackCrossPromotionImpression logCrossPromotionImpression
trackAndOpenStore logCrossPromotionAndOpenStore
setDeviceTrackingDisabled anonymizeUser

📲Installation

$ cordova plugin add cordova-plugin-appsflyer-sdk

To install cordova manually check out the doc here.

NOTE: for Ionic installation see this section

👨‍👩‍👧‍👦 Add or Remove Strict mode for App-kids

Starting from version 6.1.10 iOS SDK comes in two variants: Strict mode and Regular mode. Please read more here Change to Strict mode
After you installed the AppsFlyer plugin, go to the ios folder inside platform folder:

cd platform/ios

open the Podfile and replace pod 'AppsFlyerFramework', '6.1.1' with pod 'AppsFlyerFramework/Strict', '6.1.1'

Run pod install inside the ios folder

inside xcode, go to your target and define Preprocessor Macro AFSDK_NO_IDFA=1 Add Preprocessor macro

Change to Regular mode
Go to the ios folder inside platform folder:

cd platform/ios

open the Podfile and replace pod 'AppsFlyerFramework/Strict', '6.1.1' with pod 'AppsFlyerFramework', '6.1.1'

Run pod install inside the ios folder

inside xcode, go to your target and remove the Preprocessor Macro AFSDK_NO_IDFA=1

📖 Guides

Great installation and setup guides can be viewed here.

🚀 Setup

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.
waitForATTUserAuthorization - For iOS14 only. Time for the sdk to wait before launch.

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

document.addEventListener('deviceready', function() {

   window.plugins.appsFlyer.initSdk({
      devKey: 'K2***************99', // your AppsFlyer devKey
      isDebug: false,
      appId: '41*****44', // your ios appID
      waitForATTUserAuthorization: 10, //time for the sdk to wait before launch - IOS 14 ONLY!
    },
      (result) => {
        console.log(result);
      },
      (error) => {
        console.error(error);
      }
    );
  
}, false);

📑 API

See the full API available for this plugin.

📱 Demo

Check out the demo for this project here.
There is 1 demo project called demoC, run npm run setup_c in the appsflyer-cordova-plugin folder and then open the ios project in Xcode to see implementation for IOS 14.
Check out our Sample-App Let's cook! here if you want to implement our SDK inside React-Cordova app

📍 Ionic

NOTICE! In AppsFlyer Cordova plugin version 6.x.x we replaced the word track with log from all our api but Ionic-Navite Appsflyer plugin still uses track
So the latest version that can work with Ionic-Native for now is 5.4.30

In case you are using Ionic framework, you have 2 options:

1. Using the window object directly

Install the cordova plugin:

$ ionic cordova plugin add cordova-plugin-appsflyer-sdk

In your main ts file, declare a window variable:

declare var window;

Now you can use the AppsFlyer plugin directly from cordova:

import {Component} from '@angular/core';
import {Platform} from '@ionic/angular';

declare var window;
...
export class HomePage {
    constructor(public platform: Platform) {
        this.platform.ready().then(() => {
            window.plugins.appsFlyer.initSdk(options, success, error);
        });
    }
}

2 - Using Ionic native plugin

Ionic 4

run this commands: With Cordova:

$ ionic cordova plugin add cordova-plugin-appsflyer-sdk
$ npm install @ionic-native/appsflyer

With Capacitor:

$ npm install cordova-plugin-appsflyer-sdk
$ npm install @ionic-native/appsflyer
ionic cap sync

Then add the following to app.module.ts

import { Appsflyer } from "@ionic-native/appsflyer/ngx";
...
providers: [
Appsflyer,
...,
]

and in your main ts file:

import { Appsflyer } from '@ionic-native/appsflyer/ngx';
import {Platform} from '@ionic/angular';

constructor(private appsflyer: Appsflyer, public platform: Platform) { 
...
this.platform.ready().then(() => {
            this.appsflyer.initSdk(options);
        });
}

Ionic 2/3

If you're using Ionic 2/3, you'd need to install a previous version of the Ionic Native dependency (notice the @4 at the end of the npm install command):

$ ionic cordova plugin add cordova-plugin-appsflyer-sdk
$ npm install @ionic-native/appsflyer@4

Then add the following to app.module.ts(with no /ngx)

import { Appsflyer } from "@ionic-native/appsflyer";
...
providers: [
Appsflyer,
...,
]

And finally in your main ts file:

import { Appsflyer } from '@ionic-native/appsflyer';

Check out the full API for more information

Install

npm i cordova-plugin-appsflyer-sdk

DownloadsWeekly Downloads

1,854

Version

6.2.0

License

MIT

Unpacked Size

265 kB

Total Files

52

Last publish

Collaborators

  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar