apache / cordova-android

Apache Cordova Android
https://cordova.apache.org/
Apache License 2.0
3.59k stars 1.52k forks source link

Cordova Android 12 Permission Not prompt or request in real device #1626

Closed FanYeeChok closed 9 months ago

FanYeeChok commented 10 months ago

Bug Report

Problem

Permission not prompt in real device

What is expected to happen?

Expected to prompt permission in real device

What does actually happen?

Not prompt any permission request in real device

Information

Command or Code

Environment, Platform, Device

Version information

Checklist

masond2f commented 10 months ago

Having the same issue. I'm using file transfer and it requires android 12 to work but without prompts no permission is granted

LGuiness commented 9 months ago

I'm having the same issue.

breautek commented 9 months ago

Which permission(s) are we talking about?

Some permissions simply don't have prompts, other permissions are system level permissions only, some permissions are only valid at certain API levels, etc.

FanYeeChok commented 9 months ago

my app currently is push notification and file permission.

due to file permission, we move to this plugin https://github.com/customautosys/cordova-plugin-saf-mediastore for file storage at the moment, this will not required any file permission.

push notification have to add permission in the manifest file via config.xml https://developer.android.com/develop/ui/views/notifications/notification-permission#declare

breautek commented 9 months ago

my app currently is push notification and file permission.

due to file permission, we move to this plugin https://github.com/customautosys/cordova-plugin-saf-mediastore for file storage at the moment, this will not required any file permission.

push notification have to add permission in the manifest file via config.xml https://developer.android.com/develop/ui/views/notifications/notification-permission#declare

For some permissions, declaring them in the manifest is enough to have the permission grant. Other permissions may require an explicit permission grant from the user. It depends on the severity level of permissions. It's not cordova-android's responsibility for making these permission requests. It's up to the plugin to handle checking and requesting permissions if necessary.

my app currently is push notification and file permission.

If by file permission you mean READ_EXTERNAL_STORAGE and/or WRITE_EXTERNAL_STORAGE, on API 33 devices requesting these permissions results in an auto rejection of the permission grant. So you wouldn't see a prompt. These permissions are completely obsolete on API 33 and later and replaced by 3 other permissions. For API 32 and earler, READ_EXTERNAL_STORAGE was still used. Again it's up to the plugin to manage requesting the appropriate permission based on API level.

due to file permission, we move to this plugin https://github.com/customautosys/cordova-plugin-saf-mediastore for file storage at the moment, this will not required any file permission.

If you're using external storage (either emulated or sdcard) then this is a good move that I would have recommended. Not endorsing the specific plugin, but any plugin that uses the MediaStore API rather than File-based APIs. The scoped storage mechanism that is enforced since API 29 makes it very difficult to use external storage from a "File API" standpoint. I made a PR against the Apache File plugin that expands the docs regarding those issues: https://github.com/apache/cordova-plugin-file/pull/593

It doesn't sound like what you have reported is a bug with cordova-android, but perhaps a bug with a particular plugin. If you were using the file plugin with the external storage, then there are also a lot of other issues not necessarily related to API 33 or the permissions, which is why moving to a MediaStore plugin is probably the best move for interacting with Android's external filesystem.

Closing because this doesn't appear to be a bug with cordova-android.