feat: implement Live Activity registration service and enhance notifications handling

This commit is contained in:
2026-05-24 23:53:40 +07:00
parent d991d06f17
commit 802d32e9a0
13 changed files with 379 additions and 154 deletions
+25
View File
@@ -0,0 +1,25 @@
import Foundation
/// Wire-format identifiers for the `platform` field on the notification
/// service's `/devices` endpoint. Kept in sync with the backend's
/// `model.DevicePlatform` constants.
enum DevicePlatform {
static let ios = "ios"
static let iosLiveActivityStart = "ios-liveactivity"
/// Builds a per-activity update token platform tag. The suffix is the
/// `alertId` the Activity was started for, used by the backend to target
/// update/end pushes at a specific running Live Activity.
static func iosLiveActivityUpdate(alertId: String) -> String {
"ios-liveactivity-\(alertId)"
}
}
enum DeviceTokenFormatter {
/// APNs returns the device token as raw bytes; the HTTP/2 endpoint expects
/// a lowercase hex string. Used uniformly for APNs, Push-to-Start and
/// per-activity update tokens.
static func hex(_ data: Data) -> String {
data.map { String(format: "%02.2hhx", $0) }.joined()
}
}