cordova-plugin-android-permissions
cordova-plugin-android-permissions copied to clipboard
[feature-request] Add <uses-permission> to manifest for each requested permission
When trying to request some permission, if it is not declared on AndroidManifest.xml, Android will not even try to request it and directly return false when checking. I solved this temporally by adding this code on config.xml, maybe it can be added automatically.
<config-file parent="/manifest" target="AndroidManifest.xml"> <uses-permission android:name="android.permission.CAMERA" /> <uses-permission android:name="android.permission.RECORD_AUDIO" /> <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" /> <uses-feature android:name="android.hardware.microphone" /> </config-file>
Thanks you made my day!
If someone has problems with android
namespace, just put this in <widget>
as a property so the xml is valid:
xmlns:android="http://schemas.android.com/apk/res/android"
I agree that the plugin only asks for permissions declared with <uses-permission>
, but doesn't this defeat the use of the plugin?
I'm not an Android expert, but isn't the whole point to avoid <uses-permission>
for runtime permissions?
After all, also the Android guide describes <uses-permissions>
as problematic:
Also, when publishing an app via the Play Console such permissions are listed as "required":
...however I need these sensitive permissions only in certain rare situations and the user should not need to grant these permissions on install.
Edit: Google Play Console also won't publish the app to devices that do not support permissions listed in <uses-permission>
unless <uses-feature android:required="false" .../>
is added.
Am I missing something?
@jampy As the docs say:
Beginning with Android 6.0 (API level 23), the user can approve or reject some app permisions at runtime. But no matter which Android version your app supports, you must declare all permission requests with a
<uses-permission>
element in the manifest. If the permission is granted, the app is able to use the protected features. If not, its attempts to access those features fail.
All runtime permissions must be declared in the manifest to be able to ask for them to be granted at runtime.