AppsFlyer in ionic


#1

Anyone experienced in apply AppsFlyer cordova sdk within ionic 2?

https://github.com/AppsFlyerSDK/cordova-plugin-appsflyer-sdk -> this is plugin i tried to use but i have no idea how to initial in ionic 2 to use its function. Please help


#2

To add the plugin to your project:

ionic cordova plugin add cordova-plugin-appsflyer-sdk

To remove the plugin from your project:

ionic cordova plugin rm cordova-plugin-appsflyer-sdk

Also see: https://github.com/AppsFlyerSDK/cordova-plugin-appsflyer-sdk#-for-ionic-1


#3

Hi @robinyo,

I able to install plugin into my IONIC 2 project. Sorry but my question is how to use this plugin in the code. Based on my understanding, the plugin have to initial when using e.g. import {AppsFlyer} from ‘AppsFlyer’, it available to use its function when initial success like AppsFlyer.initSdk(’’);. Please guide how to initial the plugin to use?


#4

If you have it installed the plugin, then in your app.component.ts:

    this.platform.ready().then(() => {

      var options = {
        devKey: 'xxXXXXXxXxXXXXxXXxxxx8'  // your AppsFlyer devKey               
      };
                              
      if (ionic.Platform.isIOS()) {
       options.appId = "123456789";  // your iOS App ID in the App Store
      }

      window.plugins.appsFlyer.initSdk(options); 
    });

As per: https://github.com/AppsFlyerSDK/cordova-plugin-appsflyer-sdk#-for-ionic-1


#5

@robinyo,

Tried your way but hitting error as below
ERROR Error: Uncaught (in promise): TypeError: Cannot read property ‘appsFlyer’ of undefined
TypeError: Cannot read property ‘appsFlyer’ of undefined.


#6

That’s what it say’s in the project’s README.

Have a look at: https://github.com/AppsFlyerSDK/cordova-plugin-appsflyer-sdk/blob/master/www/appsflyer.js

And try:

  declare let AppsFlyerPlugin: any;

  ...

 constructor(...) {

    this.platform.ready().then(() => {

      var options = {
        devKey: 'xxXXXXXxXxXXXXxXXxxxx8'  // your AppsFlyer devKey               
      };
                              
      if (ionic.Platform.isIOS()) {
       options.appId = "123456789";  // your iOS App ID in the App Store
      }

      AppsFlyerPlugin.initSdk(options); 
    });
  }