Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add a plugin on only one Ionic platform?

I am using the excellent background geolocation plugin on an Ionic project. Unfortunately Apple don't think my usage is valid enough so I have to work out how to add this plugin only on Android. I can't fix this at a code level because the very existence of the plugin marks my app as requiring background geolocation in info.plist.

Is there a way in Ionic (perhaps in package.json) to flag a plugin as only to be installed on one particular platform?

like image 489
Chris Rae Avatar asked Apr 28 '16 19:04

Chris Rae


1 Answers

Maybe use plugman to add plugin for specific platform:
First,install plugman:

$ npm install -g plugman

And then, add plugin:

$ plugman install --platform <ios|android|blackberry10|wp8> --project <directory> --plugin <name|url|path>

for your situation, <directory> should be platforms/android, so the finally installation command is:

$ plugman install --platform android --project platforms/android --plugin https://github.com/mauron85/cordova-plugin-background-geolocation.git

More about plugman, refer to cordova plugman docs.Hope this will help, regards.

like image 125
liuwenzhuang Avatar answered Oct 15 '22 14:10

liuwenzhuang