4

I have wanted to implement a way of ensuring that user receive notifications, e.g. Azure NotificationHub - Detect failed notifications

However this had limited success when there was many subscribes to a tag, and then ended up with a lot server time.

Instead I found this link caching Notifications. It specifically states that toast notifications can't be cached. Nevertheless since I upgraded to the Azure App Service using Notification Hub, I have tested that toast notifications are in fact cached.

However I cannot find any documentation of caching in reference to Toasts or how to ensure the caching or how many notifications can be cached, and finally for how long?

Therefore I would like to know if anybody has any knowledge about caching and how this is specified? Example from the link above:

X-WNS-Cache-Policy: cache | no-cache

But how is this specified?

Update

The answer is correct in respect to enable caching. Nevertheless it is still unclear for me how long Notifications are cached, the link says the notifications are dropped after a reasonable amount of time, what is that?

Further it is not specified how many notifications are stored, one attribute is referred to as cycling for the link, such that if a new message is cached with the same tag, it will take the old message place. But how many different tags can be stored is not mentioned, and how to enable or disable cycling is not mentioned either ?

Finally how many messages can be cached per channel/user ?

Community
  • 1
  • 1
JTIM
  • 2,774
  • 1
  • 34
  • 74

1 Answers1

2

Azure Notification Hub doesn't set this header default. Based on the WNS documentation, by default caching is enabled.

As per WNS documentation, when the device is offline, by default WNS will store up to five tile notifications (if queuing is enabled; otherwise, one tile notification) and one badge notification for each channel URI, and no raw notifications. This default caching behavior can be changed through the X-WNS-Cache-Policy header. Note that toast notifications are never stored when the device is offline.

For explicitly setting this header, you can use Notification Hub SendNotificationAsync API to send notification. Example:

Dictionary wnsHeaders = new Dictionary();

wnsHeaders.Add("X-WNS-Cache-Policy", “cache” );

WindowsNotification notification = new WindowsNotification(“payload”, wnsHeaders);

await client. SendNotificationAsync (notification);

Sateesh
  • 376
  • 1
  • 4
  • Okay, funny that it is cached then. Could you tell about how many? For how long? And can you see how many of the messages are allready cached for that particular user/channel? – JTIM May 31 '16 at 07:21
  • do you know how to add the header in xml version, my notifications are created in this format how would I include headers? – JTIM Jun 14 '16 at 15:34