commit 75cf934e8a1ed52014241cdeb1f1b7a0fc1c91b2
parent bf9bbd051636d25c0635b93fae6ecd938b623bfd
Author: Michael Camilleri <[email protected]>
Date: Sat, 6 Jun 2026 23:10:17 +0900
Add logging to app badging
Diffstat:
2 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/Crossmate/Services/AppServices.swift b/Crossmate/Services/AppServices.swift
@@ -3084,6 +3084,12 @@ final class AppServices {
let merged = BadgeState.unreadGameIDs()
.union(coreDataUnread.keys)
.union(pendingInvites)
+ syncMonitor.note(
+ "app badge refresh: count=\(merged.count) "
+ + "ledger=\(BadgeState.unreadGameIDs().count) [\(shortIDs(BadgeState.unreadGameIDs()))] "
+ + "coreData=\(coreDataUnread.count) [\(shortIDs(coreDataUnread.keys))] "
+ + "pendingInvites=\(pendingInvites.count) [\(shortIDs(pendingInvites))]"
+ )
do {
try await UNUserNotificationCenter.current().setBadgeCount(merged.count)
} catch {
diff --git a/NotificationService/NotificationService.swift b/NotificationService/NotificationService.swift
@@ -81,6 +81,18 @@ final class NotificationService: UNNotificationServiceExtension {
let count = BadgeState.unreadGameIDs()
.union(BadgeState.pendingInviteGameIDs()).count
bestAttemptContent.badge = NSNumber(value: count)
+ VisibleNotificationReceiptLog.record(
+ body: [
+ "game=\(gameID.map { String($0.uuidString.prefix(8)) } ?? "nil")",
+ "kind=\(kind ?? "nil")",
+ "payload=\(payload == nil ? "absent" : "present")",
+ "marksUnread=\(marksUnread)",
+ "ledgerUnread=\(BadgeState.unreadGameIDs().count)",
+ "pendingInvites=\(BadgeState.pendingInviteGameIDs().count)",
+ "stampedBadge=\(count)"
+ ].joined(separator: " "),
+ source: "notification-service-extension-badge"
+ )
contentHandler(bestAttemptContent)
}