@@ -87,7 +87,6 @@ class NotificationService: UNNotificationServiceExtension {
87
87
if let lastReadIds,
88
88
lastReadIds. contains ( String ( transaction. id) ) {
89
89
shouldIgnoreNotification = true
90
- return
91
90
}
92
91
93
92
// MARK: 3. Working on transaction
@@ -333,22 +332,24 @@ class NotificationService: UNNotificationServiceExtension {
333
332
if let data = try ? JSONEncoder ( ) . encode ( transaction) , let transactionRaw = String ( data: data, encoding: . utf8) {
334
333
bestAttemptContent. userInfo [ AdamantNotificationUserInfoKeys . transaction] = transactionRaw
335
334
}
336
- bestAttemptContent. userInfo [ AdamantNotificationUserInfoKeys . decodedMessage] = decodedMessage
337
335
338
- // MARK: 8 Set current budge
339
- let storedBadgeString : String ? = SecureStore . get ( StoreKey . notificationsService. customBadgeNumber)
340
- let currentBadge = ( Int ( storedBadgeString ?? " 0 " ) ?? 0 ) + 1
341
- bestAttemptContent. badge = NSNumber ( value: currentBadge)
342
- SecureStore . set ( String ( currentBadge) , for: StoreKey . notificationsService. customBadgeNumber)
336
+ // MARK: 8 Set current budge and Message
337
+ var badgeValue = ( Int ( SecureStore . get ( StoreKey . notificationsService. customBadgeNumber) ?? " 0 " ) ?? 0 )
338
+ if !shouldIgnoreNotification {
339
+ badgeValue += 1
340
+ bestAttemptContent. userInfo [ AdamantNotificationUserInfoKeys . decodedMessage] = decodedMessage
341
+ }
342
+
343
+ bestAttemptContent. badge = NSNumber ( value: badgeValue)
344
+ SecureStore . set ( String ( badgeValue) , for: StoreKey . notificationsService. customBadgeNumber)
343
345
344
346
contentHandler ( bestAttemptContent)
345
347
}
346
348
347
349
override func serviceExtensionTimeWillExpire( ) {
348
350
// Called just before the extension will be terminated by the system.
349
351
// Use this as an opportunity to deliver your "best attempt" at modified content, otherwise the original push payload will be used.
350
- if !shouldIgnoreNotification,
351
- let contentHandler = contentHandler,
352
+ if let contentHandler = contentHandler,
352
353
let bestAttemptContent = bestAttemptContent {
353
354
contentHandler ( bestAttemptContent)
354
355
}
0 commit comments