简体   繁体   English

Cordova 权限,如何在 config.xml 中处理?

[英]Cordova Permissions, how to handle in config.xml?

When you try install my android app, it asks for a whole lot of permissions that I am not using?当您尝试安装我的 android 应用程序时,它会要求我没有使用的大量权限? How do I limit the permissions in the config.xml ?如何限制 config.xml 中的权限?

The issue is that I do not define most of those permissions in my config.xml问题是我没有在 config.xml 中定义大部分权限

<widget xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0" id="com.beerportfolio.beerportfoliopro" version="5.4.9">

    <preference name="phonegap-version" value="cli-6.3.0" />
    <preference name="android-build-tool" value="gradle" />

    <gap:plugin name="cordova-plugin-whitelist" source="npm" />
    <access origin="*" />
    <allow-navigation href="*" />
    <allow-intent href="*" />

    <name>Beer Portfolio</name>
    <description>Know Your Beer</description>
    <author href="https://www.beerportfolio.glass" email="mike@beerportfolio.glass">Mike</author>
    <content src="index.html" />
    <preference name="permissions" value="none" />
    <preference name="orientation" value="default" />

    <preference name="target-device" value="universal" />

    <preference name="fullscreen" value="false" />
    <preference name="webviewbounce" value="false" />
    <preference name="disallowOverscroll" value="true" />
    <preference name="prerendered-icon" value="true" />
    <preference name="stay-in-webview" value="false" />
    <preference name="ios-statusbarstyle" value="black-opaque" />
    <preference name="detect-data-types" value="true" />
    <preference name="exit-on-suspend" value="false" />
    <preference name="show-splash-screen-spinner" value="true" />
    <preference name="auto-hide-splash-screen" value="true" />
    <preference name="disable-cursor" value="false" />
    <preference name="android-minSdkVersion" value="10" />
    <preference name="android-targetSdkVersion" value="19" />
    <preference name="android-installLocation" value="auto" />
    <gap:plugin name="org.apache.cordova.battery-status" source="npm" />
    <gap:plugin name="cordova-plugin-camera" source="npm" />
    <gap:plugin name="org.apache.cordova.media-capture" source="npm" />
    <gap:plugin name="org.apache.cordova.console" source="npm" />
    <gap:plugin name="org.apache.cordova.contacts" source="npm" />


    <gap:plugin name="org.apache.cordova.device-motion" source="npm" />
    <gap:plugin name="org.apache.cordova.device-orientation" source="npm" />
    <gap:plugin name="org.apache.cordova.dialogs" source="npm" />
    <gap:plugin name="org.apache.cordova.file" source="npm" />
    <gap:plugin name="org.apache.cordova.file-transfer" source="npm" />

    <gap:plugin name="org.apache.cordova.inappbrowser" source="npm" />
    <gap:plugin name="org.apache.cordova.media" source="npm" />
    <gap:plugin name="org.apache.cordova.network-information" source="npm" />
    <gap:plugin name="org.apache.cordova.splashscreen" source="npm" />
    <gap:plugin name="org.apache.cordova.vibration" source="npm" />

    <icon src="icon.png" />

    <gap:splash src="splash.png" gap:platform="android" gap:qualifier="port-ldpi" />
    <gap:splash src="splash.png" gap:platform="android" gap:qualifier="port-mdpi" />
    <gap:splash src="splash.png" gap:platform="android" gap:qualifier="port-hdpi" />
    <gap:splash src="splash.png" gap:platform="android" gap:qualifier="port-xhdpi" />
    <gap:splash src="splash.png" gap:platform="blackberry" />
    <gap:splash src="splash.png" gap:platform="ios" width="320" height="480" />
    <gap:splash src="splash.png" gap:platform="ios" width="640" height="960" />
    <gap:splash src="splash.png" gap:platform="ios" width="640" height="1136" />
    <gap:splash src="splash.png" gap:platform="ios" width="768" height="1024" />
    <gap:splash src="splash.png" gap:platform="ios" width="1024" height="768" />
    <gap:splash src="splash.png" gap:platform="winphone" />
    <access origin="*" />

    <gap:plugin name=" phonegap-plugin-barcodescanner" source="npm" />


    <gap:plugin name="uk.co.workingedge.phonegap.plugin.launchnavigator" source="npm" />
    <gap:plugin name="cordova-plugin-directions" source="npm" />


    <gap:config-file platform="ios" parent="NSCameraUsageDescription" overwrite="true">
        <string>We are using the Camera to scan barcodes</string>
    </gap:config-file>

    <gap:config-file platform="ios" parent="NSPhotoLibraryUsageDescription" overwrite="true">
        <string>We are using the photo library to scan barcodes</string>
    </gap:config-file>




    <!-- iPhone / iPod Touch  - lower 4s -->
    <icon src="icon-57.png" gap:platform="ios" width="57" height="57" />
    <icon src="icon.png" gap:platform="ios" width="114" height="114" />
    <icon src="icon-72.png" gap:platform="ios" width="72" height="72" />
    <icon src="152.png" gap:platform="ios" width="152" height="152" />
    <icon src="icon-120.png" gap:platform="ios" width="120" height="120" />
    <icon src="76.png" gap:platform="ios" width="76" height="76" />
    <icon src="icon-40.png" gap:platform="ios" width="40" height="40" />

    <!-- iPhone / iPod Touch - 5-5s -->
    <icon src="icon.png" gap:platform="ios" width="60" height="60" />
    <icon src="icon.png" gap:platform="ios" width="120" height="120" />
    <!-- iPhone6-6+ -->
    <icon src="icon.png" gap:platform="ios" width="180" height="180" />

    <!-- Settings Icon -->
    <icon src="icon-29.png" gap:platform="ios" width="29" height="29" />
    <icon src="icon.png" gap:platform="ios" width="58" height="58" />

    <!-- Spotlight Icon -->
    <icon src="icon.png" gap:platform="ios" width="40" height="40" />
    <icon src="icon.png" gap:platform="ios" width="80" height="80" />

    <plugin name="cordova-plugin-whitelist" version="1" source="npm" />

    <gap:plugin name="cordova-plugin-geolocation" source="npm" />

    <feature name="http://api.phonegap.com/1.0/battery" />
    <feature name="http://api.phonegap.com/1.0/camera" />
    <feature name="http://api.phonegap.com/1.0/network" />
    <feature name="http://api.phonegap.com/1.0/notification" />

    <gap:plugin name="cordova-plugin-x-socialsharing" source="npm" />

    <allow-intent href="http://*/*" />
    <allow-intent href="https://*/*" />
    <allow-intent href="tel:*" />
    <allow-intent href="mailto:*" />
    <allow-intent href="geo:*" />
    <platform name="android">
        <allow-intent href="market:*" />
    </platform>
    <platform name="ios">
        <allow-intent href="itms:*" />
        <allow-intent href="itms-apps:*" />
    </platform>
</widget>

在此处输入图片说明

To remove all permissions just add <preference name="permissions" value="none" /> in your config.xml file.要删除所有权限,只需在config.xml文件中添加<preference name="permissions" value="none" />

Now the permissions are based on the cordova plugins used.现在权限基于使用的cordova插件。 For example if cordova-plugin-camera is used then it will automatically add the Camera permission.例如,如果使用了cordova-plugin-camera ,那么它会自动添加Camera 权限。

If cordova-plugin-geolocation is used then it will automatically add the Location permission.如果使用了cordova-plugin-geolocation ,那么它会自动添加位置权限。

So in order to remove any unwanted permissions you have to remove the plugin as well.因此,为了删除任何不需要的权限,您还必须删除插件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM