4
votes

I am investigating migrating from Azure Mobile Services push notifications to Azure Notification Hubs for two primary benefits: 1) pub/sub architecture using tags, and 2) abstracting the device registration.

However, I'm struggling to understand the pattern for device badge value management.

With mobile services push notifications it's straightforward to maintain the current badge value in the db for individual device registrations. But with Notifications Hubs where Azure maintains the 'subscribed' devices registrations and manages the fan out of device notifications, what is the best approach for the client devices to update their current badge value with Azure Notification Hubs?

I have reviewed the Azure documentation, viewed several of the excellent overview videos, such as Channel 9 Cloud Cover episode 100, but documentation and examples seem to be lacking with regard to Notification Hubs and management of badge values.

Thanks for your help, friends!

1
There's a section here (msdn.microsoft.com/en-us/library/azure/dn913746.aspx) that talks about incrementing APNS badge numbers, but unfortunately I wasn't able to get it working -- probably old documentation. Will update here if I get any further on this.weienw
@Kurt I've been trying to send a badge to an iOS device from mobile services for a long time. I can't figure out how to structure the payload. I've tried this: var payload = '{ "message" : "My message", "badge" : "100" }'; but this does not work. Since you said you already got it to work, mind sharing how you did it?oalbrecht
The badge should be a number, so var payload = '{ "message" : "My message", "badge" : 100 }';, also you will need to make sure your device's template (if you are using one) has a badge property in there. Finally, when the device registers for push notifications, make sure you add the UIRemoteNotificationType.Badge setting (for iOS 8.0+)hvaughan3
@Kurt any updates on this? Is there a proper solution now?RPM1984

1 Answers

3
votes

Unfortunately badge management is not straightforward in a pub/sub architecture. If you use tags to indicate individual users then you can keep your counter in your backend and then add it in your notification when sending to your hub.

In you are using tags as interest group, then things are not straightforward, and they depend on what you want that count to be. For some platforms (i.e. iOS and ANdroid) you can code some client code that keeps a personalized counter. Some other times however, one has to avoid keeping personalized counters and resort to use generic badges like "!" in Windows 8.