如何仅在一个 Ionic 平台上添加插件? [英] How to add a plugin on only one Ionic platform?

查看:25
本文介绍了如何仅在一个 Ionic 平台上添加插件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Ionic 项目中使用了出色的背景地理定位插件.不幸的是,Apple 认为我的用法不够有效,因此我必须弄清楚如何仅在 Android 上添加此插件.我无法在代码级别解决此问题,因为该插件的存在将我的应用程序标记为需要在 info.plist 中进行后台地理定位.

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.

Ionic 中有没有办法(可能在 package.json 中)将插件标记为仅安装在一个特定平台上?

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

推荐答案

也许可以使用 plugman 为特定平台添加插件:
首先,安装plugman:

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

$ npm install -g plugman

然后,添加插件:

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

对于你的情况,应该是platforms/android,所以最后的安装命令是:

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

有关 plugman 的更多信息,请参阅 cordovaplugman 文档.希望这会有所帮助,问候.

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

这篇关于如何仅在一个 Ionic 平台上添加插件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆