Comments (11)
@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.
@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.
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.
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.
@xallysie when using https://github.com/NeoLSN/cordova-plugin-android-permissions what permissions are you asking for?
from cordova-plugin-local-notifications.
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.
@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.
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.
@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.
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.
This sould be fixed, with the latest master.
from cordova-plugin-local-notifications.
Related Issues (20)
- Apps Now Having Problems Adding Plugin HOT 2
- Plugin get installed, app get compiled and launched on android, but notification is just not working. HOT 1
- Notification group with actions at a particular time HOT 1
- When I click notification app crashes HOT 3
- request permission is never fired at all on android 13 HOT 5
- NullPointerException from isInForeground
- NPM is still at beta 2 and beta 3 has been out since 2018 HOT 7
- "Your use of exact alarms is causing your app to crash for some Android users" on Google Play Console. HOT 10
- Cant get custom sound to work in both Android and ios HOT 8
- Google Play Console Pre-launch report | java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Class java.lang.Object.getClass()' on a null object reference HOT 3
- Gradle 9.0 Compatibility - Deprecated Gradle features were used in this build HOT 5
- progressBar is not working for ios platform? HOT 1
- notification actions are not working. HOT 5
- build success, run is not working HOT 5
- Is it possible to set color for the notification title and body texts? HOT 1
- Adding the Cordova plugin local notification plugin through Cordova resulted in the Ionic project reporting 'compile not found' when generated through build HOT 1
- how to handle notification action button with icon not text HOT 4
- Can I avoid restarting the app when click the notification action button? HOT 6
- clear() does not remove the notification on Android HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cordova-plugin-local-notifications.