From a77eb6156d48f135a41a2c55a7af3a4feb622519 Mon Sep 17 00:00:00 2001 From: Rafael Del Rey Date: Sun, 5 Apr 2026 13:07:05 -0400 Subject: [PATCH] Fix TRC bolus command not received by Trio 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. --- LoopFollow/Remote/TRC/PushMessage.swift | 8 ++------ LoopFollow/Remote/TRC/PushNotificationManager.swift | 4 ++-- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/LoopFollow/Remote/TRC/PushMessage.swift b/LoopFollow/Remote/TRC/PushMessage.swift index 09ea4e817..7c4deb73c 100644 --- a/LoopFollow/Remote/TRC/PushMessage.swift +++ b/LoopFollow/Remote/TRC/PushMessage.swift @@ -7,20 +7,16 @@ struct EncryptedPushMessage: Encodable { let aps: APSPayload let encryptedData: String - init(encryptedData: String, commandType: TRCCommandType) { + init(encryptedData: String, commandType _: TRCCommandType) { self.encryptedData = encryptedData - aps = APSPayload(alert: "Remote Command: \(commandType.displayName)") + aps = APSPayload() } struct APSPayload: Encodable { let contentAvailable: Int = 1 - let interruptionLevel: String = "time-sensitive" - let alert: String enum CodingKeys: String, CodingKey { case contentAvailable = "content-available" - case interruptionLevel = "interruption-level" - case alert } } diff --git a/LoopFollow/Remote/TRC/PushNotificationManager.swift b/LoopFollow/Remote/TRC/PushNotificationManager.swift index 1cef2ff1a..88924748b 100644 --- a/LoopFollow/Remote/TRC/PushNotificationManager.swift +++ b/LoopFollow/Remote/TRC/PushNotificationManager.swift @@ -258,10 +258,10 @@ class PushNotificationManager { request.httpMethod = "POST" request.setValue("bearer \(jwt)", forHTTPHeaderField: "authorization") request.setValue("application/json", forHTTPHeaderField: "content-type") - request.setValue("10", forHTTPHeaderField: "apns-priority") + request.setValue("5", forHTTPHeaderField: "apns-priority") request.setValue("600", forHTTPHeaderField: "apns-expiration") request.setValue(bundleId, forHTTPHeaderField: "apns-topic") - request.setValue("alert", forHTTPHeaderField: "apns-push-type") + request.setValue("background", forHTTPHeaderField: "apns-push-type") request.setValue(payload.commandType.rawValue, forHTTPHeaderField: "apns-collapse-id") request.httpBody = try JSONEncoder().encode(finalMessage)