@@ -65,7 +65,6 @@ final class AdamantNotificationsService: NSObject, NotificationsService {
65
65
private( set) var inAppVibrate : Bool = true
66
66
private( set) var inAppToasts : Bool = true
67
67
68
- private var isBackgroundSession = false
69
68
private var backgroundNotifications = 0
70
69
private var subscriptions = Set < AnyCancellable > ( )
71
70
@@ -91,6 +90,13 @@ final class AdamantNotificationsService: NSObject, NotificationsService {
91
90
. notifications ( named: . AdamantAccountService. userLoggedOut, object: nil )
92
91
. sink { @MainActor [ weak self] _ in self ? . onUserLoggedOut ( ) }
93
92
. store ( in: & subscriptions)
93
+
94
+ NotificationCenter . default
95
+ . notifications ( named: UIApplication . didBecomeActiveNotification)
96
+ . sink { @MainActor [ weak self] _ in
97
+ self ? . backgroundNotifications = 0
98
+ }
99
+ . store ( in: & subscriptions)
94
100
}
95
101
96
102
func setInAppSound( _ value: Bool ) {
@@ -249,12 +255,9 @@ extension AdamantNotificationsService {
249
255
250
256
if let number = type. badge {
251
257
DispatchQueue . onMainThreadSyncSafe {
252
- content. badge = NSNumber ( value: UIApplication . shared. applicationIconBadgeNumber + backgroundNotifications + number)
253
- }
254
-
255
- if isBackgroundSession {
256
- backgroundNotifications += number
258
+ content. badge = NSNumber ( value: customBadgeNumber + backgroundNotifications + number)
257
259
}
260
+ backgroundNotifications += number
258
261
}
259
262
260
263
let trigger = UNTimeIntervalNotificationTrigger ( timeInterval: 1 , repeats: false )
@@ -300,18 +303,6 @@ extension AdamantNotificationsService {
300
303
}
301
304
}
302
305
303
- // MARK: - Background batch notifications
304
- extension AdamantNotificationsService {
305
- func startBackgroundBatchNotifications( ) {
306
- isBackgroundSession = true
307
- backgroundNotifications = 0
308
- }
309
-
310
- func stopBackgroundBatchNotifications( ) {
311
- isBackgroundSession = false
312
- backgroundNotifications = 0
313
- }
314
- }
315
306
316
307
extension AdamantNotificationsService {
317
308
fileprivate func onUserLoggedIn( ) {
0 commit comments