Skip to content

Fix TRC bolus command not received by Trio#589

Closed
rafaeldelrey wants to merge 1 commit intoloopandlearn:devfrom
rafaeldelrey:fix/trc-background-push
Closed

Fix TRC bolus command not received by Trio#589
rafaeldelrey wants to merge 1 commit intoloopandlearn:devfrom
rafaeldelrey:fix/trc-background-push

Conversation

@rafaeldelrey
Copy link
Copy Markdown

@rafaeldelrey rafaeldelrey commented Apr 5, 2026

Summary

  • Switch TRC push notifications from apns-push-type: alert (priority 10) to apns-push-type: background (priority 5)
  • Remove alert and interruption-level fields from the APNS payload

Problem

Remote bolus commands sent via Trio Remote Control appeared to succeed (APNS returned 200) but Trio never received or acted on them. Trio's logs showed no trace of an incoming push notification.

The root cause: when apns-push-type: alert is used, iOS silently drops the notification if the receiving app (Trio) has not been granted notification permissions by the user. The command never reached AppDelegate.didReceiveRemoteNotification.

Fix

Background push notifications (content-available: 1, apns-push-type: background, priority 5) are delivered by iOS regardless of notification permission status, which is the correct mechanism for remote command delivery. This matches Apple's documentation requirements — priority 5 is mandatory when using apns-push-type: background.

Test plan

  • Send a remote bolus from LoopFollow (TRC) to a Trio device that has notification permissions denied
  • Confirm Trio receives and processes the command
  • Confirm APNS still returns 200
  • Verify other TRC commands (temp target, meal, override) also work

Switch TRC push notifications from alert to background type.
Alert-type pushes are silently dropped by iOS when Trio has not
been granted notification permissions. Background push with
content-available: 1 and priority 5 is delivered regardless,
which is the correct mechanism for remote command delivery.
init(encryptedData: String, commandType _: TRCCommandType) {
self.encryptedData = encryptedData
aps = APSPayload(alert: "Remote Command: \(commandType.displayName)")
aps = APSPayload()
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This article says background notifications should not contain alert: developer.apple.com/documentation/usernotifications/pushing-background-updates-to-your-app

@bjorkert
Copy link
Copy Markdown
Contributor

bjorkert commented Apr 9, 2026

Thanks for your interest in this.

Trio Remote Commands was originally implemented as a plain background push message, but due to the nature of how those work it was far from reliable — it works in good conditions, but otherwise the message might be delayed or not delivered at all. User reports were that too many messages didn't get through in time. In a recent change we moved to the current implementation (which also aligns with Loop/Loop Caregiver), and the success rate is much higher — user feedback supports this.

The case I think you're really getting at — messages not arriving when notifications are off for Trio — is better handled with a PR towards Trio itself: when remote commands are enabled, detect if notifications are disabled and require them to be turned on. If the notifications are disturbing, the sound option can be turned off for Trio notifications in iPhone Settings.

I'm closing this one, but feel free to comment anyway.

@bjorkert bjorkert closed this Apr 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants