Giter Club home page Giter Club logo

Comments (11)

willmero avatar willmero commented on September 27, 2024

@alexp25 I'm having the same issue here with my app not being able to request permissions initially. Did you end up getting this to work? Or how did you end up allowing a new user to grant permissions to push within your app?

from cordova-plugin-local-notifications.

cgutierrez365 avatar cgutierrez365 commented on September 27, 2024

@alexp25 I'm having the same issue here with my app not being able to request permissions initially. Did you end up getting this to work? Or how did you end up allowing a new user to grant permissions to push within your app?

I also was unable to get requestPermission working on Android 13. Besides that, every time I call the schedule function the app crashes. Instead I am using this fork (https://www.npmjs.com/package/cordova-plugin-local-notification-12) which fixes the problem of the schedule function crashing on Android 13. It also has a function called setDummyNotifications which triggers the notification permissions popup.

Update 07/26/23: I realized that branch alexp25 suggested (i.e. fquirin/cordova-plugin-local-notifications) also contains some of the fixes from cordova-plugin-local-notification-12. It also appears to work on my end.

from cordova-plugin-local-notifications.

alexp25 avatar alexp25 commented on September 27, 2024

I ended up using another plugin (https://github.com/NeoLSN/cordova-plugin-android-permissions) for requesting notification permissions on Android 12+ and the fork for the actual notifications. Haven't tried the suggested alternative yet.
Note: This only works in the release build.

from cordova-plugin-local-notifications.

xallysie avatar xallysie commented on September 27, 2024

I did something similar to @alexp25 - used the fix from https://github.com/fquirin/cordova-plugin-local-notifications and the android permissions plugin from https://github.com/NeoLSN/cordova-plugin-android-permissions to request notification permissions. This works!

...unfortunately, Android 14 (API 34) breaks it again because it now blocks permissions for SCHEDULE_EXACT_ALARM by default. I tried enabling it using the android permissions plugin but it doesn't seem to work.

from cordova-plugin-local-notifications.

orhan-swe avatar orhan-swe commented on September 27, 2024

@xallysie when using https://github.com/NeoLSN/cordova-plugin-android-permissions what permissions are you asking for?

from cordova-plugin-local-notifications.

orhan-swe avatar orhan-swe commented on September 27, 2024

It seems all notifications are needed:

var list = [
            permissions.POST_NOTIFICATIONS,
            permissions.ACCESS_NOTIFICATION_POLICY,
            permissions.RECEIVE_BOOT_COMPLETED,
            permissions.WAKE_LOCK,
            permissions.POST_NOTIFICATIONS,
            permissions.SCHEDULE_EXACT_ALARM
        ];
        permissions.hasPermission(list, function( status ){
..

This works, though on clicking the notification the app restarts

from cordova-plugin-local-notifications.

plchampigny avatar plchampigny commented on September 27, 2024

@orhan-swe I think you need to set this flag to prevent restart: <preference name="AndroidLaunchMode" value="singleInstance"/> as told in the NotificationTrampolineActivity comment

from cordova-plugin-local-notifications.

alexp25 avatar alexp25 commented on September 27, 2024

I just received the following warning in Play Console when I submitted a new update:
Your app schedules exact alarms without checking whether the SCHEDULE_EXACT_ALARM permission has been granted. This is causing your app to crash for users on Android 14 because the permission is no longer granted by default.
However, I couldn't detect any issues with notifications while testing on my device.
What exactly is SCHEDULE_EXACT_ALARM supposed to break?

from cordova-plugin-local-notifications.

xallysie avatar xallysie commented on September 27, 2024

@orhan-swe Sorry it took me a while to respond. All of the functions in your list are included in my AndroidManifest, and only two are not enabled by default (POST_NOTIFICATIONS and SCHEDULE_EXACT_ALARMS). Here is the code I use to request the POST_NOTIFICATIONS permission, which works for android 14:

function permerrorCallback() {
                        console.warn('You have not granted this app permission to receive notifications. Please navigate to Settings > App Info and toggle notifications for this app.');
                    };
function permsuccessCallback( status ) {
                        if( !status.hasPermission ) permerrorCallback();
                    };
permissions.requestPermission(permissions.POST_NOTIFICATIONS, permsuccessCallback, permerrorCallback);

And this is the code I use to request the SCHEDULE_EXACT_ALARM permission, which does nothing:

function permerrorCallback() {
                        console.warn('You have not granted this app permission to receive notifications. Please navigate to Settings > App Info and toggle notifications for this app.');
                    };
function permsuccessCallback( status ) {
                        if( !status.hasPermission ) permerrorCallback();
                    };
permissions.requestPermission(permissions.SCHEDULE_EXACT_ALARM, permsuccessCallback, permerrorCallback);

Not exactly sure why. Both use the plugin created NeoLSN.

from cordova-plugin-local-notifications.

xallysie avatar xallysie commented on September 27, 2024

quick update for anyone following this issue:

I made a small plugin that addresses the SCHEDULE_EXACT_ALARM permissions issue for Android 14+.

https://github.com/xallysie/cordova-plugin-android14-schedule-exact-alarm
https://www.npmjs.com/package/cordova-plugin-android14-schedule-exact-alarm?activeTab=readme

from cordova-plugin-local-notifications.

GitToTheHub avatar GitToTheHub commented on September 27, 2024

This sould be fixed, with the latest master.

from cordova-plugin-local-notifications.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.