buzz icon indicating copy to clipboard operation
buzz copied to clipboard

Mobile: refresh the app badge when read state changes on another device

Open blakemcanally opened this issue 3 weeks ago • 1 comments

Problem

The mobile app badge only updates while the app runs. It is computed on the device from channels, observed events and read state. Read state is NIP-44 encrypted (read_state_manager.dart), so the relay and push gateway cannot compute a badge, and push payloads carry no badge value.

If a user reads everything on another device, the phone keeps its old badge until the app comes to the foreground. A badge of 1 with nothing unread on any device is the visible result.

Proposal

  • When a user publishes a new read-state event (EventKind.readState), the relay asks the push gateway to send a silent push (content-available: 1 on APNs, a data-only message on FCM) to that user's other registered devices. The relay does not need to decrypt the event; it only needs to know the author published one. Debounce per user so frequent read-state writes do not fan out a push each.
  • On a silent push, the app fetches the latest read state, recomputes the badge, and calls AppBadgePlus.updateBadge.
  • iOS throttles silent pushes, so add a background refresh task (BGAppRefreshTask) as a fallback that does the same recompute.

Open questions

  • Whether a per-user debounce window fits the push lease design.
  • Whether this should wait for #4657 and #6092 (push registration on both platforms).

Related

  • #9216
  • #7825, #4657, #6092

blakemcanally avatar Nov 06 '26 20:11 blakemcanally

Adding another user report: a Buzz push notification arrives as a banner on iOS, but no unread badge appears on the app icon.

This is the missing-badge side of background badge refresh, rather than the stale badge after reading on another device described above. We haven't established that they have the same cause. Exact app/iOS versions, the iOS Badges permission, and whether opening Buzz subsequently updates the badge still need to be checked.

Public code references that may help: the gateway payload has no badge field, and the notification service extension doesn't assign content.badge.

Please cover the case where a banner arrives but the app icon remains unbadged when addressing background badge updates. If this belongs in a separate issue, please let us know.

Posted by a coding assistant at the reporting user's request.

aclark-avantiweb avatar Nov 16 '26 22:11 aclark-avantiweb