bhandaribhumin / cordova-plugin-local-notification-12

Apache License 2.0
17 stars 35 forks source link

Problem with cordova.plugins.notification.local.requestPermission() on Android 12 and higher #14

Open sergip76 opened 8 months ago

sergip76 commented 8 months ago

On Android 12 and higher cordova.plugins.notification.local.requestPermission() does not work and permission is always false

bhandaribhumin commented 8 months ago

@sergip76 please try setdummynotification()

https://github.com/bhandaribhumin/cordova-plugin-local-notification-12#setdummynotification

matodrobec commented 8 months ago

Hi, how can i use setDummyNotifications()? I try this code but it do nothing

this.localNotifications
            .requestPermission((granted) => {
                console.log('localNotifications.requestPermission', granted);
                if (granted) {
                    result.resolve(true);
                } else {
                    this.localNotifications.setDummyNotifications();
                    result.reject(false);
                }
            });
jondspa commented 6 months ago

Hi bhandaribhumin -

Any thoughts on the Android 13 permissions problem? setDummyNotifications() isn't working for me, either. I'd be willing to contribute for your time in fixing this :-)

I saw someone on another plugin board posted this code but I couldn't get it work.

 private void requestPermission(CallbackContext callbackContext) {
     if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
       // Create a notification channel for Android 8.0 and above
      createNotificationChannel();

     if (NotificationManagerCompat.from(context).areNotificationsEnabled()) {
       callbackContext.success("Notification already enabled");
     } else {
       Intent intent = new Intent(Settings.ACTION_APP_NOTIFICATION_SETTINGS);
       intent.putExtra(Settings.EXTRA_APP_PACKAGE, context.getPackageName());
       context.startActivity(intent);
    }
  }
}
pltnik commented 6 months ago

I tried this plugin (version 0.1.4) on my Android 13 and there is too some issue with permission. I tried also "cordova.plugins.notification.local.setDummyNotifications();" but nothing happen. When I manually enabled notifications, it was working. So for Android 13 it is needed to open application settings and the user has to enable permission.