Skip to content

Keeping the widget current

The home screen widget shows the reminder, or the next appointment in its place. A widget cannot fetch anything itself: expo-widgets only reads the timeline the app last saved to the App Group folder. Until November 5, 2026, a reminder saved on the web reached the widget only after the senior next opened the app.

Thomas asked on November 5, 2026 for the widget to update without the app being opened. Of three ways offered, he chose a silent push when a Loved One saves a change, with a background refresh as the safety net when a push is missed. The third, a native widget that fetches for itself, would have meant replacing expo-widgets.

How it works

  1. The phone sends its push token. At launch, on a switch of person, and when the phone pairs, the app gets its Expo push token and sends it to the Worker for the active senior's bank (PUT /banks/:bankId/push-token, push_tokens, migration 0027). A token moves to whichever bank it last named. Disconnect asks the Worker to forget it (DELETE).
  2. A Loved One saves a change. Saving or removing the reminder, or adding, changing, or removing an appointment, sends each of the bank's phones a silent push through Expo's push service (apps/api/src/push.ts), after the Worker has answered. It has no words, sound, or badge, only _contentAvailable, so iOS shows nothing and wakes the app in the background instead. A token Expo says is no longer registered is deleted.
  3. The app wakes and fetches. The silent push runs a background task (PUSH_TASK) that fetches the active senior's reminder and schedule, keeps them for the start screen, and hands the widget a new timeline (refreshWidgetFromBank, src/features/widget/background-refresh.ts).
  4. The safety net. iOS also runs REFRESH_TASK now and then (expo-background-task), at least an hour apart and often only overnight, which does the same fetch. It also restarts the widget's week-long timeline from that day.

The phone's session is in the Keychain. A background wake may come while the phone is locked, so sessions are saved readable once the phone has been unlocked after it started (AFTER_FIRST_UNLOCK), rather than only while unlocked. Sessions saved by Build 57 and earlier are moved over once, at the first launch in the foreground (keepSessionsReadableInBackground).

What can hold it back

  • iOS decides. Apple asks for no more than two or three silent pushes an hour, and may delay or drop them, for instance in Low Power Mode. A few changes in a row on the web are fine; the last push fetches everything.
  • An app swiped away from the app switcher gets no silent pushes until it is opened again. The background refresh may not run for it either.
  • A failed push never stops the save. The Worker logs it, and the phone catches up at its next refresh or launch.

Setting it up

  • APNs key in EAS. Expo's push service sends through Apple with the project's push key. Set one up once with cd ~/Documents/GitHub/SilverApp/apps/mobile && npx eas credentials (iOS, production, Push Notifications: set up a push key). Without it, Expo answers each push with an error and the safety net is all that runs.
  • Push security. If the Expo project turns on enhanced push security, set an access token as the Worker secret EXPO_ACCESS_TOKEN (npx wrangler secret put EXPO_ACCESS_TOKEN in apps/api). It is not needed otherwise.
  • The push environment. Preview and production builds use the production push environment (aps-environment, set in app.config.ts from EAS_BUILD_PROFILE); development builds keep the development one. A simulator gets no push token; the app logs that and carries on.
  • A native change. The background modes (remote-notification, processing) and the task identifier come from config plugins, so this needs a new build.

Tests

  • apps/api/tests/routes/push-tokens-routes.test.ts: the token route, the push sent to each of the bank's phones and no one else's, a token Expo has forgotten removed, and a push after each change to the reminder and the schedule.
  • apps/mobile/tests/widget-refresh.test.tsx: both tasks fetch and update the widget, and tell iOS how it went; the push token sent and sent again on pairing; nothing on Android.
  • apps/mobile/tests/bank-session.test.ts: sessions saved readable in the background, and the one-time move of older ones.