Closed jeffreytck closed 6 years ago
It is!
You can access AppsFlyer Plugin like this:
declare var window: any;
...
window.plugins.appsFlyer.initSdk(options, onSuccess, onError);
There is no ionic-native plugin, so you have to create your own models and use them.
Create models as in AppsFlyer spec, e.g. in src/app/models/appsflyer.options.model
export class AppsFlyerInitOptions {
public devKey: string;
public appId?: string;
public isDebug?: boolean;
public onInstallConversionDataListener?: boolean;
}
export class AppsFlyerTrackEventOptions {
public eventName: string;
public eventValues: Object;
}
export class AppsFlyerConstants {
public static DEV_KEY: string = 'YOUR_DEV_KEY';
public static APP_ID: string = 'YOUR_APP_ID';
}
now init appsflyer:
import { AppsFlyerInitOptions, AppsFlyerConstants } from "./models/appsflyer.options.model";
declare var window: any;
class YOUR_CLASS {
[...]
// init AppsFlyer
const options = new AppsFlyerInitOptions();
options.devKey = AppsFlyerConstants.DEV_KEY;
options.isDebug = false;
options.onInstallConversionDataListener = true;
if (this.platform.is('ios')) options.appId = AppsFlyerConstants.APP_ID;
try {
const onSuccess: Function = (res: any) => {
console.debug("AppsFlyer SDK successfully initiated:", res);
};
const onError: Function = (err: any) => console.error("ERROR: Could not init AppsFlyer SDK", err);
window.plugins.appsFlyer.initSdk(options, onSuccess, onError);
}
catch (e) {
console.error("ERROR: AppsFlyer not initiated", e);
}
[...]
}
Halleluyah! =)
please suggest more code After using code from top comment ive got error TypeError: Cannot read property 'appsFlyer' of undefined
@sebastianbaar
Make sure you are calling window.plugins.appsFlyer.initSdk...
when platform is ready, like this:
this.platform.ready().then(() => {
window.plugins.appsFlyer.initSdk(options, onSuccess, onError);
});
...oh and of course window.plugins
is only available on devices! is not available in the browser!
Cheers
Hello again @sebastianbaar thank you for tips. I have already integrated. Is there any StartTracking method on plugin? Because after integration my TEST says:
??Tracking is not started
My environment info
cli packages:
@ionic/cli-utils : 1.19.2
ionic (Ionic CLI) : 3.20.0
global packages:
cordova (Cordova CLI) : 8.0.0
local packages:
@ionic/app-scripts : 3.1.8
Cordova Platforms : none
Ionic Framework : ionic-angular 3.9.2
System:
Android SDK Tools : 25.2.5
Node : v8.10.0
npm : 5.8.0
OS : Windows 8
Misc:backend : pro```
cordova-plugin-appsflyer-sdk 4.4.0 "AppsFlyer"
Same issue as Fayozjon. Maybe when we call initSdk in app.component.ts it's didn't bind to MainActivity so it's didn't work. (?)
On iOS either I can't track non-organic install.
Any help from someone ?
@Antoine8469 in my case if even debug application says that its not installed properly on dashboard i have some metrics so its works but debug app says not.
Just install it as shown its will work
also added template for Ionic 3: https://github.com/AppsFlyerSDK/cordova-plugin-appsflyer-sdk/tree/master/examples/Ionic3/src
Please share/comment isn't this plugin support ionic 2 as well? If yes, how to initialize this plugin in ionic 2 project?