0
votes

I have added firebase analytics to my project.

For this I did the following:

Step 1: ionic cordova plugin add cordova-plugin-firebase-analytics (I assume that this means latest version)

Step 2: npm install --save @ionic-native/[email protected]

I have to specify the @4.20.0 during npm install because if I don't do so, then the (\node_modules@ionic-native\firebase-analytics) module doesn't have the FirebaseAnalytics class exported, but the FirebaseAnalyticsOriginal.

I understand that the step 2 is a wrapper to use plugin from step 1. I am confused about the difference between the version of plugin cordova-plugin-firebase-analytics v/s @ionic-native/firebase-analytics

Any information on this will be helpful.

1

1 Answers

1
votes

When you install any cordova plugin, you are exposed with only JS wrappers to use it from your TS code using clobbers/merges target.

merges target of (cordova-plugin-firebase-analytics) : https://github.com/chemerisuk/cordova-plugin-firebase-analytics/blob/master/plugin.xml#L14

JS Exposed functions of (cordova-plugin-firebase-analytics) : https://github.com/chemerisuk/cordova-plugin-firebase-analytics/blob/master/www/FirebaseAnalytics.js

So now if you want to access any function of that plugin, you will do like below in your TS code :

declare var cordova: any;
cordova.plugins.firebase.analytics.resetAnalyticsData();

Now coming to @ionic/native Wrappers. These are the Typescripts wrappers written by ionic-team for common plugins, which are used by developers all around the globe. These wrappers make life simple on integrating the plugins with Typescript.

Here are the @ionic/native Wrappers for (cordova-plugin-firebase-analytics) - https://github.com/ionic-team/ionic-native/blob/master/src/%40ionic-native/plugins/firebase-analytics/index.ts