简体   繁体   中英

Updating notification badge after dissmissing notification from Notification Center

My app uses Local Notifications. There are situations when more than one notification is scheduled and at some point displayed. When notifications are displayed badge number is updated automatically. When user clicks on one of the notifications I manually decrease badge number and cancel the notification.

The problem starts when user manually dismisses notification from Notification Center. The badge number is not updated. There are situations when there are no notifications displayed in Notification Center and badge shows a number. User is not able to clear the badge.

Setting the badge number to 0 (instead of decreasing it) after clicking on one of the notifications is not an option because it causes all notifications to disappear from Notification Center.

Is there a good way to resolve this issue?

Is there a good way to resolve this issue?

No.

Your app isn't notified when a user dismisses the local notification. Only push notifications can set the badge number when your app isn't running.

The badge is intended to represent the internal state of some data in your app that you control. There is no way to make it always match the number of items in the user's notification center. This is also why you get no notification if the user cancels your local notification.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM