Post

Replies

Boosts

Views

Activity

Reply to How to increase notification badge number dynamically when local notification is delivered?
@Claude31 ::: Ok, thank you for the information. I will check this out and see what I can do. I just thought there would be a more automatic way of handling this since every App pretty much wants to increment the badge number by 1. I can decrement the badge number in my UNUserNotificationCenterDelegate Class via a custom "cancel" notification action... for example, UIApplication.shared.applicationIconBadgeNumber -= 1 ... So, I thought that there was a way to add 1 to whatever is already delivered too.
Apr ’21
Reply to How to increase notification badge number dynamically when local notification is delivered?
@Claude31 ::: Would this work with something like I'm doing? Remember, I set up all the notifications (50 of them) in my App while it is running. Then, the user exits (most likely) and just waits for the notifications to be delivered at their set calendar date/time. I know how to look at delivered notifications while the App is open but I'm not sure how I would code this in my UNUserNotificationCenterDelegate Class if I wanted to check this and then somehow have the correct badge number calculated (Note: UNUserNotificationCenterDelegate is where I can check to see how users interacted with the notifications and respond via custom actions that I set). If I tried a monitoring loop, wouldn't that only work if the App is open? Where in my code would I put that?
Apr ’21
Reply to How to increase notification badge number dynamically when local notification is delivered?
So, I'm running a loop that basically sets 50 notifications at a time. In the loop, I set the content, let content = self.notificationContent(title: "my title", body: "whatever else I want to say") content.threadIdentifier = "my.thread" content.categoryIdentifier = "my.category" content.badge = self.counter as NSNumber  // -- this counter gets incremented for each iteration of the loop //.. Calendar trigger var dateComponents = Calendar.current.dateComponents([.year, .month, .day, .hour, .minute, .second], from: myTime) let trigger = UNCalendarNotificationTrigger(dateMatching: dateComponents, repeats: false) let identifier = "message.notify.reset\(self.notifyNumber)" let request = UNNotificationRequest(identifier: identifier, content: content, trigger: trigger) //.. Add it to notification center UNUserNotificationCenter.current().add(request) { (error) in       self.printError(error, location: "*** Add request for identifier: " + identifier)  } Then, once that one is added, I increment the counter and add the next one. It does all of this correctly but it's not really what I want to happen because once the notifications are set, it's basically out of my App... and whichever one triggers next, is the number that shows up for the badge. So, for example, if number 48 is the one that gets sent at 8pm, the badge now says 48 regardless of whether or not the user "cleared" any/all of the other notifications prior to that. What I would like to see happen somehow is for the notification manager to recognize that when a new notification is delivered, it needs to look at the previous count for the badge number and then increment that by 1. So, if it was previously 7 for the badge number, it should be 8 after the next notification is delivered. Maybe it's me, but this seems kind of obvious/basic that that's the way it should work. Am I missing something? Is there a way to do this?
Apr ’21