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

request permission is never fired at all on android 13 #2012

Closed
kotran88 opened this issue Oct 12, 2023 · 5 comments
Closed

request permission is never fired at all on android 13 #2012

kotran88 opened this issue Oct 12, 2023 · 5 comments

Comments

@kotran88
Copy link

ionic v3
it never fire any push notification permission . and when I look into permission, push notification is off.


    "@ionic-native/local-notifications": "^4.20.0",
    "cordova-plugin-local-notification": "git+https://github.com/fquirin/cordova-plugin-local-notifications.git",

ionic info


   Ionic CLI          : 5.4.16 (/Users/pedrojung/.nvm/versions/node/v14.20.1/lib/node_modules/ionic)
   Ionic Framework    : ionic-angular 3.9.2
   @ionic/app-scripts : 3.2.1

Cordova:

   Cordova CLI       : 11.0.0 ([email protected])
   Cordova Platforms : android 10.1.2
   Cordova Plugins   : no whitelisted plugins (33 plugins total)

Utility:

   cordova-res                          : 0.15.4
   native-run (update available: 1.7.3) : 1.7.1

System:

   Android SDK Tools : 26.1.1 (/Users/pedrojung/Library/Android/sdk/)
   ios-deploy        : 1.12.1
   NodeJS            : v14.20.1 (/Users/pedrojung/.nvm/versions/node/v14.20.1/bin/node)
   npm               : 6.14.17
   OS                : macOS Sonoma
   Xcode             : Xcode 15.0 Build version 15A240d
@ZarishIqbal
Copy link

@ZarishIqbal
Copy link

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);
      }
    }
  }

Or change the native code to this.

@jondspa
Copy link

jondspa commented Nov 8, 2023

Hi ZarishIqbal -

Thanks for posting the code. I'm trying to work with your code to fix the Android 13 permission problem. I've looked at https://github.com/ZarishIqbal/cordova-local-notifications-plugin and don't see where you're requestPermission() function.

I''d like to integrate your requestPermission() function into https://github.com/bhandaribhumin/cordova-plugin-local-notification-12 which is what I've been using for a while.

Many thanks!
- Jon

@jondspa
Copy link

jondspa commented Nov 14, 2023

Figured it out. Use the plugin https://github.com/NeoLSN/cordova-plugin-android-permissions and then it's simple.

 var permissions = cordova.plugins.permissions;
 permissions.requestPermission(permissions.POST_NOTIFICATIONS, successPermissionNotification, errorPermissionNotification);

and of course add POST_NOTIFICATION to your Android Manifest file.

@GitToTheHub
Copy link
Collaborator

This should be fixed, with the latest master.

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

4 participants