Reputation: 2827
In my database i store the delivered message count in a table field. For every message i sent to a particular device, i will increment this value.
When the device receive payloa with badge set, it display the red circle on the application icon.
This is all ok but, when i launch application (from push or directly from icon), how i can inform the server that have reset the counter ?
And, if the application is active, i have to inform the server too to not increment the badge (because the user is reading in real time).
To manage this, i have to call-back the server for every push i receive ?
Upvotes: 0
Views: 692
Reputation: 393841
IF you want the server to know when the user viewed the new data (either by launching the app, or already having the app in the foreground), the only way, as you already figured out, is to call-back your server every time the app is either launched (from the notification or the icon) or receives a push notification while active.
If the app is active, you can immediately remove the badge when you handle the push notification (so the user will never see it). You do it in application:didReceiveRemoteNotification:
by calling app.applicationIconBadgeNumber = 0
.
Upvotes: 1