fquirin / cordova-plugin-local-notifications

Cordova Local-Notification Plugin (fixed fork)
Apache License 2.0
13 stars 27 forks source link

[Question] Notifications not working on Android 14 #6

Open PreciousBiscuit opened 9 months ago

PreciousBiscuit commented 9 months ago

Does anyone know why notifications are not working on Android 14? What is the difference between Android 13 and 14, and what needs to be changed in the plugin code to make it work? There is no error, debug info, nothing in the logcat.

Thank you for any helpful pointers.

Your Environment

PreciousBiscuit commented 9 months ago

So far I have found out that the plugin uses setExact() methods which require USE_EXACT_ALARM permission on Android 14. However using this permissions may cause the Play Store to decline the app.

xallysie commented 9 months ago

I'm experiencing the same issue. To bypass the Play Store policy, the plugin may need to be updated to schedule inexact alarms instead, so the notification fires within an hour of the set time.

PreciousBiscuit commented 7 months ago

Unfortunately that is not acceptable solution for our app. So for now I have made fork that uses USE_EXACT_ALARM permission and I will see if Google starts crying or not. Fork link: https://github.com/PreciousBiscuit/cordova-plugin-local-notifications

TeoMastro commented 7 months ago

Hello, since I have the same issues with you @PreciousBiscuit and I actually tried the exactly same thing you did, I still have the google play console error. Our app is in internal testing and I have also made an issue (https://github.com/katzer/cordova-plugin-local-notifications/issues/2016) to the fork with the most stars so everyone can see. There I describe my findings and what I have found so far as a possible solution. Did your fork fix the problem? Thanks in advance.

TeoMastro commented 7 months ago

@xallysie I saw your plugin (https://github.com/xallysie/cordova-plugin-android14-schedule-exact-alarm/blob/main/src/android/com/android/plugins/ScheduleExactAlarm.java). This seems to be an acceptable approach to the exact alarms problem for Android 14 (I mean the logic according to the android documentation). Will you try to implement an approach like that to an existing fork?

PreciousBiscuit commented 7 months ago

Hi @TeoMastro , my fork only changed permissions and nothing else. I'm not aware of any crashes nor any console error in the Google store. If there was any issue (a crash, an error, not working notifications) I would have been notified.

TeoMastro commented 7 months ago

Hello @PreciousBiscuit. In an older app that uses the plugin the error does not exist. But now that we uploaded a fresh app we saw this error in the console using the exact same plugin. Note that both apps target the same SDK (33)

PreciousBiscuit commented 7 months ago

Unfortunately I have no way to verify that myself. We don't have any other app that would use this plugin (yet). However our app targets SDK 33 as well. Just asking, because I'm not sure which fork you have tried or what changes you have made, but are you sure you didn't change anything that could cause crashes? Or other thing that comes to mind is that there is a bug on Google side. :)

TeoMastro commented 7 months ago

Yes I am 100% positive. I found something that might fix the problem but I am still testing it. If I have any updates I will let you know all.

xallysie commented 7 months ago

@xallysie I saw your plugin (https://github.com/xallysie/cordova-plugin-android14-schedule-exact-alarm/blob/main/src/android/com/android/plugins/ScheduleExactAlarm.java). This seems to be an acceptable approach to the exact alarms problem for Android 14 (I mean the logic according to the android documentation). Will you try to implement an approach like that to an existing fork?

That plugin is still in development and I haven't been able to get it to work yet. If someone could take a look at the code and see what needs to be done, that'd be appreciated!

Edit: nvm, I realized that SCHEDULE_EXACT_ALARM follows a different logic than other types of permissions (which @TeoMastro alluded to!). Simplified the plugin so that it opens the Alarms & Reminders setting and prompts users to toggle enable the permission themselves. They will then use the back arrow at the top of the page to return to the app.

It seems this is how google intended this permission to be requested, so my plugin can be used safely with this fork. yay!