dpa99c / cordova-diagnostic-plugin

Cordova/Phonegap plugin to manage device settings
539 stars 361 forks source link

No working POST_NOTIFICATIONS #493

Closed SinGlEBW closed 1 year ago

SinGlEBW commented 1 year ago

cordova -v: 11.0.0 "android-minSdkVersion" value="22" "android-targetSdkVersion" value="31" "android-compileSdkVersion" value="31"

    Does not output Permission
    diagnostic.requestRuntimePermission((status) => { console.log(status) }, () => {}, diagnostic.permission.POST_NOTIFICATIONS)
dpa99c commented 1 year ago

If you don't implement the error callback, you won't know if the reason that the success callback is not being called is because the error callback is: () => {} Check you have added the permission to your manifest, build and run the example project to validate your development environment

mirko77 commented 1 year ago

POST_NOTIFICATIONS always returns DENIED_ALWAYS when targeting API 33 in Android 11, even when the notification permission is granted. (which is the default, on Android 12 and below it doesn't prompt for permission because you can always receive push notifications.)

Works in Android 13 API 33, no problems. It triggers the prompt on first install, then the status is correct.

dpa99c commented 1 year ago

I can reproduce the same outcome: building with API 33 on device running Android 11, the permission result from Android is DENIED for POST_NOTIFICATIONS. You'd think the correct response from Android would be GRANTED since it's implicitly granted since Android 11 doesn't implement POST_NOTIFICATIONS as a run-time permission. I'll update the plugin code to handle this correctly.