Calendar icon indicating copy to clipboard operation
Calendar copied to clipboard

Missing Calendar Reminders on Android 14

Open Neiyk opened this issue 1 year ago • 25 comments

Checklist

  • [X] I can reproduce the bug with the latest version given here.
  • [X] I made sure that there are no existing issues - open or closed - to which I could contribute my information.
  • [X] I made sure that there are no existing discussions - open or closed - to which I could contribute my information.
  • [X] I have read the FAQs inside the app (Menu -> About -> FAQs) and my problem isn't listed.
  • [X] I have taken the time to fill in all the required details. I understand that the bug report will be dismissed otherwise.
  • [X] This issue contains only one bug.
  • [X] I have read and understood the contribution guidelines.

Affected app version

1.0.3

Affected Android/Custom ROM version

Android 14

Affected device model

Samsung Galaxy S22

How did you install the app?

Google Play Store

Steps to reproduce the bug

  1. Install Fossify Calendar on Android 14 device
  2. Grant Fossify Calendar all needed Permissions
  3. Exclude Fossify Calendar in Android settings from Energy saving
  4. Allow Fossify Calendar in Android settings to run all the time in Background
  5. Set an time in Fossify Calendar in two hours with two different times 30 minutes before and one at begin
  6. Close all apps
  7. wait for reminder
  8. Repeat steps 1. to 7. but now restart your smartphone instead of closing all apps

Expected behavior

All timer reminders should appear exactly on time

Actual behavior

Timer reminders from Fossify Calendar are missing, coming to late or will come only if the app will opened manually

Screenshots/Screen recordings

No response

Additional information

Hello,

Fossify Calendar (and also Simple Calendar) do not activate the reminders on the right time, many hours to late or only if the calendar app will manually opened on Android 14 (might be also an issue on Android 13). The issue appears even Fossify Calendar is excluded from Android energy saving and allowed all the time to run in the background.

As you can also see on the Google Play store reviews for Simple Calendar many users have the same issue with missing or "forgotten" reminders.

The cause seems the changed permissions rights in Android 13/14 to set exact timers as documented in Google Developer forum.

I have two different Samsung Galaxy smartphones with Android 14 (and One UI Version 6.0) with that issue.

Could you please check/fix that issue and test it with an Android 14 device?     Schedule exact alarms are denied by default (more details see on source page) https://developer.android.com/about/versions/14/changes/schedule-exact-alarms :

Schedule exact alarms are denied by default

Exact alarms are meant for user-intentioned notifications or actions that need to happen at a precise time.

SCHEDULE_EXACT_ALARM, the permission introduced in Android 12 for apps to schedule exact alarms, is no longer being pre-granted to most newly installed apps targeting Android 13 and higher (will be set to denied by default). If the user transfers app data to a device running Android 14 through a backup-and-restore operation, the permission will still be denied. If an existing app already has this permission, it'll be pre-granted when the device upgrades to Android 14.

The SCHEDULE_EXACT_ALARM permission is required to initiate exact alarms via the following APIs or a SecurityException will be thrown:

  • setExact()
  • setExactAndAllowWhileIdle()
  • setAlarmClock()

Existing best-practices for the SCHEDULE_EXACT_ALARM permission still apply, including the following:

  • Check the permission with canScheduleExactAlarms() before scheduling exact alarms.
  • Set up your app to listen and properly react to the foreground broadcast AlarmManager.ACTION_SCHEDULE_EXACT_ALARM_PERMISSION_STATE_CHANGED, which the system sends when the user grants the permission.

Affected apps

If a device is running Android 14 or higher, this change will affect a newly installed app that has the following characteristics:

  • Targets Android 13 (API level 33) or higher.
  • Declares the SCHEDULE_EXACT_ALARM permission in the manifest.
  • Doesn't fall under an exemption or pre-grant scenario.
  • Isn't a calendar or alarm clock app.

Calendar and alarm clock apps should declare USE_EXACT_ALARM

Calendar or alarm clock apps need to send calendar reminders, wake-up alarms, or alerts when the app is no longer running. These apps can request the USE_EXACT_ALARM normal permission. The USE_EXACT_ALARM permission will be granted on install, and apps holding this permission will be able to schedule exact alarms just like apps with the SCHEDULE_EXACT_ALARM permission."

  See also

Android 12: Using SCHEDULE_EXACT_ALARM permission to get/show data at specific time are safe in Google Play Policy? https://stackoverflow.com/questions/71031091/android-12-using-schedule-exact-alarm-permission-to-get-show-data-at-specific-t

Android 14 - Behavior changes: all apps Core functionality -> Schedule exact alarms are denied by default https://developer.android.com/about/versions/14/behavior-changes-all

Neiyk avatar Apr 27 '24 16:04 Neiyk

If anybody else also encounters this bug, please write your device model and OS version. I have Android 14 (OnePlus 9 Pro), and all reminders are working correctly. On Android 13 I also didn't have any problems with that.

Aga-C avatar Apr 27 '24 16:04 Aga-C

I have the same issue as OP. Redmi Note 11 5G (evergo), Android 13, MIUI 14.0.4. The stock calendar app reminder works fine.

DazzyWalkman avatar May 06 '24 02:05 DazzyWalkman

The cause seems the changed permissions rights in Android 13/14 to set exact timers as documented in Google Developer forum.

It's already using the new USE_EXACT_ALARM permission: https://github.com/FossifyOrg/Calendar/blob/a83b9419aec0f63ffced5b5ddb95f4184b56e5a0/app/src/main/AndroidManifest.xml#L12

(Though I have no idea what else the issue could be, nor have a Android 14 device to test.)

nofishonfriday avatar May 09 '24 00:05 nofishonfriday

Same issue on Nokia One Plus with Android 11, Fossify Calendar v1.0.3 from F-Droid. All battery optimisations turned off (Battery manager off, don't optimize battery for Fossify Calendar, override "do not disturb"). Also followed the instructions at https://dontkillmyapp.com/hmd-global without luck. If I create an event with a reminder within a few hours, it works for that event, but if it's a recurring event, it won't notify the next day or any day thereafter.

The solution to this might be to create a persistent foreground service that prevents the app from being killed. Perhaps it can also "refresh" the alarms if they get killed/removed.

tobykurien avatar Jun 25 '24 14:06 tobykurien

Same issue on Xiaomi Mi Note 10 Lite with Android 12 Fossify Calendar v1.0.3 from F-Droid

My work around: Export all to a isc file, delete all appointments and reimport all after restart.

cahogithub avatar Jul 27 '24 13:07 cahogithub

Same issue on Nokia One Plus with Android 11, Fossify Calendar v1.0.3 from F-Droid.

A workaround for me is to install the Calendar Notifications app from F-droid which works just fine: https://f-droid.org/en/packages/com.github.quarck.calnotify/

Perhaps the devs can look into what that app has done to make the notifications work reliably (even without using the setAlarmClock method in the settings of that app).

tobykurien avatar Aug 08 '24 07:08 tobykurien

Same issue on Nothing Phone (2a), Android 14, battery usage set to unrestricted. I created a test event few minutes in the future and got notified OK. Then I left the phone on the table over night and in the morning notifications for ordinary events didn't go off.

jenda69 avatar Aug 29 '24 06:08 jenda69

Same issue on Xiaomi 12T, Android 14 UP1A.230905.011 , security update 2024-09-01. If I set reminder "one hour before" event, the notification is delayed. For example, I set an event at 13h and a reminder one hour before, then I receive the notification at 12h07.

adrnam avatar Nov 18 '24 11:11 adrnam

I asked the Phind AI:

"I search the bug https://github.com/FossifyOrg/Calendar/issues/217 in the Fossify Calendar Android app. The app is open source: https://github.com/FossifyOrg/Calendar Any idea what the problem is?"

"Yes, I can identify the problem with the Fossify Calendar app. This is a known issue related to Android 14's new permission handling system for exact alarms. Here's what's happening:

Current Problem

  • Reminders aren't triggering at the correct time
  • They either arrive many hours late or only work when the app is manually opened
  • This occurs despite proper battery optimization settings

Technical Cause "The root cause is Android 14's new security policy regarding exact alarms. As of Android 14, the SCHEDULE_EXACT_ALARM permission is denied by default for most newly installed apps. Even though Fossify Calendar is configured to run in the background and is exempt from battery optimization, it needs a specific permission to function correctly."

flowchart LR
    Start[App Installation] --> Check{Calendar/Alarm<br/>App Type?}
    
    Check -->|No| Default["Default Behavior:<br/>• Exact Alarms Denied<br/>• Use Inexact Alarms"]
    
    Check -->|Yes| Target{"Target API ≥ 33?"}
    
    Target -->|No| Legacy["Legacy Behavior:<br/>• Exact Alarms Allowed<br/>• No Special Setup Needed"]
    
    Target -->|Yes| Declare{"Declared<br/>USE_EXACT_ALARM?"}
    
    Declare -->|No| Error["Error State:<br/>• Cannot Set Exact Alarms<br/>• SecurityException Thrown"]
    
    Declare -->|Yes| Success["Success:<br/>• Exact Alarms Granted<br/>• Full Reminder Functionality"]

    style Start fill:#f9f,stroke:#333,color:#000
    style Default fill:#ffcccc,stroke:#333,color:#000
    style Legacy fill:#ccffcc,stroke:#333,color:#000
    style Error fill:#ff9999,stroke:#333,color:#000
    style Success fill:#99ff99,stroke:#333,color:#000

To understand the diagram above:

  • API level 33 refers to Android 13 - apps targeting this version or higher (like Fossify Calendar v1.0.3) are affected by these new restrictions
  • As a calendar app, Fossify falls into the "Calendar/Alarm App Type" category, which gives it access to special permissions
  • Currently, the app is hitting the error state because while it declares the basic permission, it needs to explicitly declare USE_EXACT_ALARM to work properly on Android 14

Solution The developers need to update the app's manifest file to include the USE_EXACT_ALARM permission declaration. This is specifically designed for calendar and alarm clock applications that require precise timing for reminders. Once implemented, this permission will be granted automatically during installation, restoring proper reminder functionality."

"The error also occurs on older Android versions (e.g. 12). Does your solution solve this problem as well?"

"Based on the original issue description, the problem indeed affects multiple Android versions, including Android 12. Let me explain how the solution addresses this broader scope:

flowchart TD
    subgraph "Pre-Installation"
        A[App Installation] --> B{Calendar/Alarm<br/>App Type?}
    end
    
    subgraph "Permission Handling"
        B -->|No| C["Default Behavior:<br/>#8226; Exact Alarms Denied<br/>#8226; Use Inexact Alarms"]
        
        B -->|Yes| D{Target API Level}
        
        D -->|"≥ 31 (Android 12)"| E["Declare<br/>SCHEDULE_EXACT_ALARM"]
        D -->|"≥ 33 (Android 13+)"| F["Declare<br/>USE_EXACT_ALARM"]
    end
    
    subgraph "Runtime Behavior"
        E --> G{Permission<br/>Granted?}
        F --> H{Permission<br/>Granted?}
        
        G -->|Yes| I["Full Alarm<br/>Functionality"]
        G -->|No| J["Limited Alarm<br/>Behavior"]
        
        H -->|Yes| K["Full Alarm<br/>Functionality"]
        H -->|No| L["Limited Alarm<br/>Behavior"]
    end
    
    classDef default fill:#f9f9f9,stroke:#333,stroke-width:1px,color:#000000
    classDef success fill:#d4edda,stroke:#28a745,stroke-width:2px,color:#000000
    classDef warning fill:#fff3cd,stroke:#ffc107,stroke-width:2px,color:#000000
    classDef error fill:#f8d7da,stroke:#dc3545,stroke-width:2px,color:#000000
    
    class I,K success
    class J,L warning
    class C error

To help interpret the diagram above:

  • API levels correspond to Android versions: Level 31 = Android 12, Level 33 = Android 13/14
  • "Full Alarm Functionality" means reminders work exactly as scheduled
  • "Limited Alarm Behavior" represents the current issue where reminders are delayed or only trigger when the app is opened manually

The solution I proposed earlier actually addresses the problem across all affected Android versions because:

Android 12 (API 31):

  • Requires the SCHEDULE_EXACT_ALARM permission
  • Once declared, the permission is typically granted automatically
  • Same underlying mechanism causing the issue (restricted exact alarms)

Android 13/14 (API 33+):

  • Uses the newer USE_EXACT_ALARM permission
  • More restrictive by design
  • Automatically granted for calendar apps upon installation

The fundamental issue remains consistent across versions: the app needs explicit permission to schedule exact alarms. While the specific permission name differs between Android 12 and later versions, declaring the appropriate permission will resolve the reminder delays regardless of the Android version. This explains why users on Android 12 are experiencing similar issues - it's the same core problem of restricted exact alarm permissions, just with slightly different implementation details. The solution of adding the appropriate permission declaration will work across all affected versions, ensuring timely reminders for all users."

cahogithub avatar Feb 15 '25 11:02 cahogithub

Nice use of mermaid by phind there but the app does that already. It uses the USE_EXACT_ALARM permission on API 33+.

Also, AIs can't solve problems with little to no context.

The problem seems related to how events are rescheduled in BootCompletedReceiver.

naveensingh avatar Feb 15 '25 11:02 naveensingh

Yes, you are right. The AI has no web browsing capabilities and cannot access the project's source code. It was worth a try.

cahogithub avatar Feb 15 '25 12:02 cahogithub

I haven't given up yet. I delivered it the AndroidManifest.xml. It suggested the following changes:

<!-- Add to manifest permissions -->
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />

<!-- Modify BootCompletedReceiver -->
<receiver
    android:name=".receivers.BootCompletedReceiver"
    android:exported="true">
    
    <intent-filter>
        <action android:name="android.intent.action.BOOT_COMPLETED" />
        <!-- Existing actions remain -->
    </intent-filter>
</receiver>

<!-- Add Notification Service declaration -->
<service
    android:name=".services.SnoozeService"
    android:exported="true"
    android:foregroundServiceType="alarm|reminder">

While the BootCompletedReceiver is properly declared, there are two critical missing elements:

  • Missing android.permission.POST_NOTIFICATIONS permission declaration
  • No foreground service declaration needed for Android 9+

The SnoozeService lacks proper configuration:

  • No exported flag specified
  • Missing foreground service declaration
  • No notification channel setup

cahogithub avatar Feb 16 '25 13:02 cahogithub

Thanks but you need to know what you are doing and then it maybe able to help.

Besides, I have assigned the issue to myself and I'll fix it before the next update.

naveensingh avatar Feb 16 '25 14:02 naveensingh

Fair enough. Thank you for taking care of it!

cahogithub avatar Feb 18 '25 18:02 cahogithub

It's that easy, @naveensingh.

nvllz avatar Mar 14 '25 10:03 nvllz

@nvllz PR is welcome ¯\_(ツ)_/¯

naveensingh avatar Mar 14 '25 10:03 naveensingh

Just thought you couldn't figure it out.

nvllz avatar Mar 14 '25 10:03 nvllz

@nvllz Have you actually checked the code before posting? Calendar uses USE_EXACT_ALARM which unlike SCHEDULE_EXACT_ALARM your link is referring to doesn't require user permission afaik. So it doesn't seem to be that easy. :)

nofishonfriday avatar Mar 14 '25 16:03 nofishonfriday

@nofishonfriday idk man, if the app uses the permission correctly then something else is wrong here. I was looking for the fix baited by this fragment posted above:

The root cause is Android 14's new security policy regarding exact alarms. As of Android 14, the SCHEDULE_EXACT_ALARM permission is denied by default for most newly installed apps. Even though Fossify Calendar is configured to run in the background and is exempt from battery optimization, it needs a specific permission to function correctly.

Some more niche apps like MedTimer are perfectly reliable and have this "alarms and reminders" switch in app info screen butFossify Calendar doesn't. That's why I was looking for a fix in this direction, sorry if it's a miss. Just got mad because of a missed event reminder while everything was fine on my old Android 13 device and I got used to this app. On Android 15 reminders aren't so reliable, and this thing was introduced just recently, hence I thought it's about the SCHEDULE_EXACT_ALARM.

nvllz avatar Mar 14 '25 19:03 nvllz

Well the first post from which you quoted also says:

Calendar and alarm clock apps should declare USE_EXACT_ALARM Calendar or alarm clock apps need to send calendar reminders, wake-up alarms, or alerts when the app is no longer running. These apps can request the USE_EXACT_ALARM normal permission. The USE_EXACT_ALARM permission will be granted on install, and apps holding this permission will be able to schedule exact alarms just like apps with the SCHEDULE_EXACT_ALARM permission."

Besides, @naveensingh seems to have basically figured it out already.

No worries though, I can understand getting mad about an expected reminder not firing. :)

nofishonfriday avatar Mar 14 '25 20:03 nofishonfriday

I have this problem that some events' notifications do not activate. Not been able to determine a pattern yet though tested with single and repetitive events.
Phone is Android 10 Honor View 20 with latest version of Calendar. Obviously annoying not being able to rely on event notifications. Willing to help triage if people can suggested things to try. Thanks,

jackthebean avatar Apr 26 '25 12:04 jackthebean

Based on my observations, it's either marking as done or deleting past tasks (including the first occurrence) that interrupts recurring task notifications for me. Either or both of these prevent further notifications from appearing for me. One-time events are firing properly, which may mean it's a broader problem than just missing permissions.

Edit: after brief testing I'm almost sure it's deleting initial task/event that breaks notifications for next occurrences.

nvllz avatar Apr 30 '25 11:04 nvllz

I have done some testing over the past few days. Set up a few one-off events and a daily recurring one. All worked both on first day and subsequent days so definitely not just affecting all recurrent. In fact had a one-off event today with 3 reminders (5 days, 1hr and 30mins). Can't remember about the 5 day one but definitely not the 1hr or 30 mins one.

Affects lots of events. Maybe ones with multiple reminders??

jackthebean avatar Apr 30 '25 18:04 jackthebean

All worked both on first day and subsequent days so definitely not just affecting all recurrent

Did you delete the first one? I've made it clear that after deleting the first day's event, it's broken for the next notifications. Try it yourself.

nvllz avatar Apr 30 '25 18:04 nvllz

I don't think I have ever deleted the first event and so that is not the cause in, at least almost all of, my cases but I will set up a test event and see what happens.

I currently have a weekly event for Thurs at 7.45am with reminders both 12 hrs and 10 mins before but neither go off now though they used to.

In fact I think it worked for quite some weeks so maybe the issue is due to: 1 Number of weeks since first/set up. 2 Upgrade to Fossify Calendar or DAVX5

jackthebean avatar May 01 '25 09:05 jackthebean