Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
sergip76 opened this issue Aug 24, 2023 · 4 comments

Comments

@sergip76
Copy link

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

@bhandaribhumin
Copy link
Owner

@matodrobec
Copy link

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
Copy link

jondspa commented Nov 9, 2023

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 :-)

  • Jon

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
Copy link

pltnik commented Nov 15, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants