NeoLSN / cordova-plugin-android-permissions

This plugin is designed for supporting Android new permissions checking mechanism.
Apache License 2.0
274 stars 178 forks source link

Permissions not popping up #124

Open willPHPwork opened 1 year ago

willPHPwork commented 1 year ago

I'm using permissions.requestPermission(permission, successCallback, errorCallback); but nothing shows up. I an on android 13 and SDK 33.

var permissions = cordova.plugins.permissions;

permissions.requestPermission(permissions.CAMERA, success, error);

function error() {
  console.warn('Camera permission is not turned on');
}

function success( status ) {
  if( !status.hasPermission ) error();
}

Has a success callback but shows hasPermission: false without showing ability to grand permission.

Works fine in Android 12.

dillanspencer commented 1 year ago

me too brother. :(

NeilCresswell commented 1 year ago

We've had no problems checking or requesting the CAMERA permission using this plugin and are also targeting SDK 13, and have tested this successfully on real Android 11, 12 and 13 devices, where we've then been able to access the camera after granting the permission.

Here are our relevant API level settings from config.xml:

    <preference name="android-minSdkVersion" value="30" />
    <preference name="android-targetSdkVersion" value="33" />
    <preference name="android-compileSdkVersion" value="33" />

Possibly if you don't have it, you may want to try changing the compileSdkVersion to 33 as well as the targetSdkVersion? Not sure if that will help but wouldn't hurt to try. Our minSdkVersion is just to limit our users to Android 11 or higher as we don't want to support earlier versions than that.

We also have these settings in the config.xml, that you will also need for the camera permission:

    <platform name="android">
        <config-file parent="/*" platform="android" target="AndroidManifest.xml">
            <uses-feature android:name="android.hardware.camera" android:required="false" />
            <uses-permission android:name="android.permission.CAMERA" />
        </config-file>
    </platform>

Editing to add that our Cordova Android platform is v12.0.1.

LucasBourgeois commented 1 year ago

Hi ppl,

Any workaround about this ? Im facing the same problem : I do use permChecker.requestPermission(permChecker.CAMERA, success, err). But, success callback is called and response in it indicates : {hasPermission: false} but isnt showing at all android perm asking popup.

But if i just ignore this plugin and allow android to handle it by itself, popup is showing and everything goes well.

My assumption is that maybe Android changed something in android 13 that now, prevent this plugin to show permission asking popup.

But im no native dev.

Any more ideas about this ?

@NeilCresswell Are you sure that permissions werent granted before you tested your implementation ? As it's working like a charm with no popup showing if i do has permission prior to call the plugin. but if not, i always get hasPermission: false (which is right) but the popup asking for it isnt showing

meeNakshiDev97 commented 1 year ago

Hi, i am facing the same problem with request permission (permission.WRITE_EXTERNAL_STORAGE) in Android 13,target SDK 33.It returns haspermission false always without asking permission pop. It's working fine in Android 12 or below. I have already upgraded my target and compile SDK version to 33 . Any solution or workaround?

kenjan1974 commented 1 year ago

android-targetSdkVersion:33 android-compileSdkVersion:33 Android: 13

I have the same problem. requestPermissions() doesn't show permission popup.

aktivdigital-frontend commented 1 year ago

Same problem here. requestPermissions() doesn't show permission popup.

Any workaround about this ?

android-minSdkVersion" value="22" android-targetSdkVersion" value="33" android-compileSdkVersion" value="33"

amaphildev commented 1 year ago

Same problem, no error.

Cordova android 10.1.2 android-targetSDKVersion=33 android-minSdkVersion=30 android-compileSdkVersion=33

dominik-haupt commented 7 months ago

Hi all,

just in case this helps someone: I had the same issue where I couldn't get the Camera permission to pop up and the solution pretty much was what Neil suggested in this post. The plugin cannot request permissions that aren't declared in AndroidManifest.xml To my surprise, cordova-plugin-camera doesn't actually use the Camera permission, as they don't use the Camera directly. So I've had to add the permission semi-manually. To my config.xml, I've added the following:

<config-file parent="/manifest" target="AndroidManifest.xml">
   <uses-permission android:name="android.permission.CAMERA" /> 
</config-file>

After that, I received aapt error while building, the solution to that was to modify the <widget> tag in the config.xml I've added the following attribute to the <widget> tag: xmlns:android="http://schemas.android.com/apk/res/android"

All credit goes to Neil and this post: https://github.com/NeoLSN/cordova-plugin-android-permissions/issues/84

Thank you guys for solving this headache for me. Also, I'm on cordova-android 11.0.0

abutizi commented 4 months ago

Hi, thank you all for participating in this beautiful plugin.

I would appreciate it if you guys can help me out here. I'm using ionic 7 on android 13 with this plugin. However, the when trying to read a file from the External filesystem, i get this error:

'Error launching app update Please grant read external storage permission'.

Then when I try to run this code:

` const permissions = cordova.plugins.permissions; console.log(permissions);

await permissions.checkPermission(permissions['READ_EXTERNAL_STORAGE'], async checkResult => { console.log(checkResult); if (!checkResult.hasPermission) { await permissions.requestPermission(permissions['READ_EXTERNAL_STORAGE'], async requestResult => {

        console.log(requestResult);

    }, err => {
        console.log('err', err);
    });

} else {
    console.log(`already granted`);
}

}, err => { console.log('err', err);

});`

I get {hasPermission: false} on both has and requestPermission. I already have defined the permission in my AndroidManifest.xml

`

`

Same result with REQUEST_INSTALL_PACKAGES. I have no idea what to do here, I've been stuck on this for 2 days now straight. Any insight or help would be greatly rewarded with appreciation :3

faugusztin commented 4 months ago

READ_EXTERNAL_STORAGE doesn't exist from API level 33, you can't request it and system will not grant it. External storage is complicated from Android 13 - https://developer.android.com/about/versions/13/behavior-changes-13#granular-media-permissions

karimaswan22 commented 3 months ago

Sorry guys for late , here is the solution I think we need to keep adding that for every persmission we gonna use from now on

<platform name="android">

  <config-file parent="/*" platform="android" target="AndroidManifest.xml">
        <uses-feature android:name="android.hardware.camera" android:required="false" />
        <uses-permission android:name="android.permission.CAMERA" />
    </config-file>

....