How To: Send and Expire a Tile Notification from Mobile Services Server Scripts
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!
Comments
- Anonymous
November 25, 2015
Thank you Enzo