Skip to content

Commit 0e183b7

Browse files
committed
Reduce push-to-start apns-expiration from stale date to 10 minutes
8 hours is too generous — delivering a start notification with hours-old glucose data is worse than not starting at all. 10 minutes is long enough to survive a brief connectivity gap while the reading is still meaningful. https://claude.ai/code/session_01GJZERMhqLmEy8p4cpVX53q
1 parent 5040c77 commit 0e183b7

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

LoopFollow/LiveActivity/APNSClient.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,11 @@ class APNSClient {
142142
request.setValue("\(bundleID).push-type.liveactivity", forHTTPHeaderField: "apns-topic")
143143
request.setValue("liveactivity", forHTTPHeaderField: "apns-push-type")
144144
request.setValue("10", forHTTPHeaderField: "apns-priority")
145-
// Expire at the stale date rather than immediately so APNs can deliver
146-
// the start notification after a brief connectivity gap.
147-
request.setValue("\(Int(staleDate.timeIntervalSince1970))", forHTTPHeaderField: "apns-expiration")
145+
// 10-minute expiry — long enough to survive a brief connectivity gap
146+
// while the glucose reading in the payload is still clinically meaningful.
147+
// The stale date (8 h) is too generous: delivering a start with hours-old
148+
// glucose data is worse than not starting at all.
149+
request.setValue("\(Int(Date().timeIntervalSince1970) + 10 * 60)", forHTTPHeaderField: "apns-expiration")
148150
// Collapse key prevents duplicate LA creation if two sends race (e.g., a
149151
// refresh tick and a user-initiated restart overlap).
150152
request.setValue("\(bundleID).la.start", forHTTPHeaderField: "apns-collapse-id")

0 commit comments

Comments
 (0)