Jeff Sanders Technical Blog

I am a Microsoft employee that has worked on all aspects of the Web Stack for a long time. I hope these blogs are useful to you! Use this information at your own risk.


<< Go Back

How To Send And Expire A Tile Notification From Mobile Services Server Scripts

- 13 Mar 2013

We document how to send push notifications using Mobile Services fairly well.  You can use the wns object and push the notification.  This is documented here:

Get started with push notifications in Mobile Services 

Push notifications to users by using Mobile Services

What is not documented until now is how to expire the notification after a certain time period.  This is actually very easy (especially now that I have documented it)!

What you want to do is to pass this header: X-WNS-TTL and the number of Seconds you wish this notification to live.  Here is an example of how to do this:

 

push.wns.sendTileSquareBlock(
   item.channel,
   { text1: item.id, text2: item.text },
   {
       headers: { ‘X-WNS-TTL’: 30 },
       success: function (error, result) {
           console.log(error);
           console.log(result);
       }
   });

This example will expire the tile 30 seconds from now.  The key here is that the second object passed now has the headers option specified (https://github.com/tjanczuk/wns).

Here is some further documentation on that header:

Push notification service request and response headers – X-WNS-TTL

 

Let me know if this helps!

<< Go Back