import UserNotifications /// Sets the app icon badge to an unread count. /// /// A push carries `aps.badge` and iOS applies it on arrival, so the badge /// is right the moment a notification lands. It is not right afterwards: /// nothing tells iOS the count dropped when the inbox is read in the app, /// and the number sits there until the next push. These calls close that. /// /// The value is always the active account's unread count. The badge is /// per-device and unread is per-account, so with two accounts signed in /// the last writer wins — a push for one account, then a dashboard load /// on the other, disagree. Exact for a single account. /// /// Failures are ignored. A badge that did not take is not worth telling /// anyone about, and the next writer corrects it. func setAppBadge(_ count: Int) async { try? await UNUserNotificationCenter.current().setBadgeCount(max(0, count)) }