Question
Can you update the badge number using silent push notifications?
Answer
The short answer is no — this is an Apple limitation by design.
Understanding Silent Push Notifications
Silent push notifications are designed to trigger background tasks without alerting the user directly. They are used primarily to refresh content or update the app state quietly. However, their utility in updating the app icon badge is severely limited by Apple’s policies.
Why Silent Push Notifications can’t update the badge
iOS does not allow silent push notifications to change the badge number on the app icon directly. Even if the badge number is included in the payload, the system will not update it automatically when the notification is silent. This is an intentional restriction from Apple to ensure that any user-visible changes, such as badge updates, occur only when appropriate.
Furthermore, newer iOS versions impose additional restrictions on silent pushes. All background actions initiated by these notifications are subject to evaluation by the Duet Activity Scheduler Daemon (DASD). This system assigns a score based on several factors, such as:
-
Current battery level
-
Frequency of app usage
-
Time since the app was installed
-
Current processor temperature
Only if the action’s score is high enough will the background task be executed. As a result, even if a silent push is delivered, the background process might be delayed or canceled altogether, making it an unreliable method for timely updates.
Possible workaround
Given these limitations, relying on silent pushes for badge updates is not advisable. A more effective strategy is to use silent push notifications to trigger your app to fetch the latest badge count from your server in the background. Once the app retrieves the new count, it can update the badge number locally using the following code:
UIApplication.shared.applicationIconBadgeNumber = newBadgeCount
This approach ensures that the badge update occurs while the app is either in use or recently active, keeping the badge count synchronized without depending on the unreliable delivery of silent pushes.
See also: Setting up badges in Pushwoosh documentation
Comments
0 comments
Article is closed for comments.