1

I have to reduce Notification badge count from the App icon when user removed the notification from Notification center.

Same is possible in Android link: how to use delete intent to perform some action on clear notification?

J_B_UK
  • 347
  • 5
  • 12
Pawan Kumar
  • 508
  • 3
  • 19
  • There is no way to get a callback if one of your notifications has been cleared from the Notification Centre. You would need to do the update of your badge count when your app runs. You can use `UNUserNotificationCenter.current().getDeliveredNotifications(completionHandler)` to get a list of delivered notifications. – J_B_UK Jan 21 '21 at 11:19
  • @J_B_UK Ok but I want to get callback when user swipe the notification so that I can reduce badge count? – Pawan Kumar Jan 21 '21 at 11:31
  • If the user partially swipes you will see the options Manage, View, Clear and if they press View this will launch your app and you will be notified of this via the `didReceiveRemoteNotification` call. But if they swipe all the way across it triggers the Clear option and there isn't a way to be notified of this. – J_B_UK Jan 21 '21 at 11:37
  • The only possible partial workaround I can think of is to implement background fetch, then use the background run time to check what notifications are in the Notification Center and update the badge. This has it's drawbacks though as it will only be called when the system sees fit and if the user terminates the app completely from the app switcher then it wont be called at all. – J_B_UK Jan 21 '21 at 11:47

0 Answers0