Reputation: 31
We are already done with the initial setup for implementing Push notifications and are able to send/receive notifications successfully.
Now, we have been looking for the possible solutions to handle badge count increment from ios app (especially when app is not in foreground) -
1. Delegate the badge count calculation to server side. - If we think of offloading the task of badge calculation to app server, then question arises is that, how server side will get to know about the count of viewed notifications so that badge can be decremented accordingly.
2. Use UIBackgroundModes and call 'didReceiveRemoteNotification:fetchCompletionHandler' method. - Apple says, this method will get called when my app is either in foreground or background state. With this we should be able to track the count/notification info even when the app is in background & thus it probably enables us to do the necessary calculation in iOS app itself. However, we have noticed that this method doesn't invoke when app is in background. Does it work only for iOS Silent notifications.
Any guidance/help in this regard will be greatly appreciated.
Thanks.
Upvotes: 1
Views: 1365
Reputation: 22651
Option 1 is done by most apps (WhatsApp, Mail). It means you have to send a lot of 'notification read' messages to the server.
As for option 2, it works only for silent notifications (as you already noted) and in my experience, it is not entirely reliable. There even seems to be a rate limit on these.
Upvotes: 1