I have a server that sends me push notifications and let\'s say that I have 5 notifications on my phone. If I open one of them all other notifications disappears. I want onl
The solution is to set the applicationIconBadgeNumber
to the real number of notifications the user has in the notification center. I made a function for this:
func updateIconBadge() {
UNUserNotificationCenter.current().getDeliveredNotifications { notifications in
DispatchQueue.main.async {
UIApplication.shared.applicationIconBadgeNumber = notifications.count
}
}
}
For more info (like where to call to this function) you may want to check my original answer here: https://stackoverflow.com/a/54296486/8157190