ai-assisted-todolist

Reminders#

The app reminds without a server (#273): local notifications it schedules itself (decisions/mobile-app.md). Once at 08:00 on days tasks are due, and at a task's time when it has one (#478).

What it does#

The phone's time zone in the JavaScript engine#

Hermes, the app's JavaScript engine, reads the phone's time zone once and keeps it for every Date until the app restarts; React Native does not tell it about a change. So after a change of zone the board's "here" times, and the reminders the app scheduled at its next load, were still worked out for the old zone, until the app was ended and started again (#526). Foundation, which expo-localization reads the phone's zone from on iOS, caches it the same way.

A local Expo module of the app's own, mobile/modules/time-zone-cache/, drops both caches: Hermes' through its resetTimezoneCache(), on iOS Foundation's as well. The app calls it each time it comes back to the foreground, before the start over it does then anyway, so the board and the reminders scheduled next take the new zone. It runs even while a form holds the start over back, so the board is drawn in the new zone once the form is closed. Should it fail, the app carries on in the old zone, as before.

Not covered: a change of zone while the app stays in the foreground the whole time. The next return to the foreground puts it right.

Asking for permission#

Not at the start. The first time the board shows an open task due today or later, a note above it asks "Get notified about due and changed tasks?", with Turn on and Not now. It is the offer of the pushes too (#277): iOS and Android have one notification permission per app, so one answer covers both (push.md), and on the builds with push it comes though nothing is due. A line under it says what comes and what may happen next (#336, #478, #277): At 08:00 on days tasks are due, and at a task's time if it has one: how many, not which. And when a task changes on another of your devices: which one. If your phone asks next, allow it. Without it, the system's question after Turn on came out of nowhere, on Android at least. "If", because Android 12 and older never ask; and it does not name the app, since the phone's question names the installed variant (TaskFest QA).

On Android the reminders have their own channel, Due tasks, so they can be switched off there without touching anything else -- the pushes' is Changed tasks -- and the status bar shows the mark's single-colour form (mobile/assets/notification-icon.png).

On time, on Android#

Without exact alarms, Android may bring a reminder late: within an hour of its time, and later in Doze or with the battery saver on (alarms (opens in a new tab)). Which a phone has depends on its Android, as expo-notifications schedules exactly whenever it may (ExpoSchedulingDelegate):

Measured on the Android 14 emulator (#665): six reminders, due 20 to 150 minutes after they were scheduled, the app in the background. Awake is the screen on and the phone charging; Doze the screen off, unplugged, and Doze forced on. Each time is how late the notification was there; the script looked every 15 seconds.

Due after Inexact, awake Inexact, Doze Exact, Doze
20 min 14½ min 15 min 14 s
45 min 33 min 16 min 3 s
70 min 8½ min 52 min 8 s
100 min 60 min 22½ min 14 s
130 min 30 min 54 min 5 s
150 min 10½ min 34½ min 9 s

Inexact, Android allowed itself three quarters of the time until the reminder, and an hour at most (dumpsys alarm's window), and used most of it, awake as well. In two and a half hours of Doze none came later than that. A phone that lies still longer, such as overnight before the 08:00 reminder, gets its maintenance windows ever less often (Doze (opens in a new tab)), which the emulator did not show. Exact, every reminder came on time.

Allowing them (#665) is done in the system settings: Apps → Special app access → Alarms & reminders → TaskFest, where the permission the app declares, SCHEDULE_EXACT_ALARM, is switched on and off. The app offers it once:

Seen on the emulator:

Only a board loaded from the backend schedules reminders (#273): opened offline, the app shows the board it kept and schedules nothing.

Code and tests#

Piece Where
The rule: which days, which time, how many mobile/src/reminders.ts
The platform: permission, channel, scheduling mobile/src/notifications.ts (expo-notifications)
When they are scheduled, cleared and offered mobile/src/TaskFestApp.tsx
Exact alarms on Android: the permission, the offer, and scheduling anew in the foreground (#665) android.permissions in mobile/app.config.ts, createExactAlarmOffer in mobile/src/notifications.ts, mobile/src/TaskFestApp.tsx, mobile/src/Main.tsx
Moving them with the time zone, on iOS calendarOf in mobile/src/notifications.ts, used by mobile/src/Main.tsx
Moving them with the time zone, on Android mobile/plugins/android/TimeZoneChangedReceiver.kt, declared by mobile/src/timeZoneReceiver.ts, added by mobile/plugins/withTimeZoneReceiver.ts
Following the phone's zone in JavaScript (#526) mobile/modules/time-zone-cache/, called from mobile/src/TaskFestApp.tsx

reminders.test.ts covers the rule, notifications.test.ts the platform's use, and TaskFestApp.reminders.test.tsx the app's, TaskFestApp.exactAlarms.test.tsx the offer of exact alarms; TaskFestApp.timeZone.test.tsx that the zone is dropped on return to the foreground. On the emulator, mobile/maestro/reminders/turn-on.yaml adds a task due tomorrow and turns the reminders on, reminders/exact-alarms.yaml opens the setting for exact alarms from the note and comes back without allowing them -- every other flow runs with them allowed, so the note does not push the board's rows down -- and reminders/timed.yaml adds one due tomorrow at 09:00 (#478). run-on-emulator.sh then checks that Android holds pending alarms of the app's for 08:00 and for 09:00 in the emulator's time zone — any day's, since a run may cross midnight. It then moves the emulator to Los Angeles and checks the alarms are at 08:00 and 09:00 there (#479): left where they were, they would be at midnight and 01:00, or an hour later in summer. West, because a zone east of UTC could put tomorrow's 08:00 there before the moment of the check late in the day, which the receiver rightly leaves alone; the emulator's own zone comes back afterwards.