Localytics with Ionic


I’ve found https://github.com/localytics/localytics-cordova by localytics, but I’m not sure how to include OS specific app keys?

The instructions say to include the following:


In your <ApplicationName>-Info.plist, add the following under <dict> node:


In AndroidManifest.xml, add the following under <application> node:

<meta-data android:name="LOCALYTICS_APP_KEY" android:value="YOUR_APP_KEY" />

But I’m assuming this needs to go elsewhere to be included? Is that correct? Any guidance would be appreciated.


These instructions want you to change files in the /platform folders manually. This was needed with older Cordova versions, where you couldn’t do this automatically. Now Cordova can do this automatically from the config.xml in your app root.

(You will have to google for the correct syntax though, don’t have it handy)


Actually, it is even easier as this can be part of the plugin.xml (not config.xml as I wrote - and so being part of the plugin, not your app config) and someone already did it for Android:

Nothing for iOS though :confused:


where do I find plugin.xml in ionic 2+? I’m not seeing that file in the root or src directories.


This is in the plugin being installed, so /plugin/localytics-cordova probably.

But you shouldn’t edit this manually: You should fork the localytics-cordova plugin on Github, then apply the changes from the PR and then install the plugin from your Github url - just replace localytics-cordova with your Github repo URL in the ionic/cordova plugin add ... command. Otherwise this can break in a million different ways.


Is there no better way to overwrite parts of the plugin.xml without having to go through all that?


plugin.xml is partly evaluated at the installation of the plugin to do stuff (like changing the Android manifest in the /platforms folder via https://cordova.apache.org/docs/en/7.x/plugin_ref/spec.html#config-file - which the PR I found for you uses).

The other danger is it all going to shit when you do “something” - as /plugins is not checked into source control (as of .gitignore) this change can just “go away” if you do stuff.

(Although you could look into installing a plugin not via the string or Github URL but by file (.zip maybe?) - then you can just download the plugin, apply the PR and do this all locally somehow. Still, easier to fork and apply - it’s not that complicted once you did it the first time)