This topic shows you how to use a custom API to support periodic notifications in a Windows Store app. With period notifications enabled, Windows will periodically access your custom API endpoint and use the returned XML, in a tile-specific format, to update the app tile on start menu. For more information, see Periodic notifications.

This code returns the top 3 uncompleted items from the TodoItem table, then loads them into a JSON object passed to the wns.createTileSquareText01 function. This function returns the following tile template XML:

The exports.get function is used because the client will send a GET request to access the tile template.

NOTE:

This custom API script uses the Node.js wns module, which is referenced by using the require function. This module is different from the wns object returned by the push object, which is used to send push notifications from server scripts.

Next, you will modify the quickstart app to start periodic notifications that update the live tile by requesting the new custom API.

Update the app to turn on period notifications

In Visual Studio, press the F5 key to run the quickstart app from the previous tutorial.

Make sure at least one item is displayed. If there are no items, type text in Insert a TodoItem, and then click Save.

In Visual Studio, open the App.xaml.cs project file and add the following using statement:

This code turns on period notifications to request tile template data from the new tiles custom API. Select a [PeriodicUpdateRecurrance] value that best matches the update frequency of your data.

Test the app

In Visual Studio, press the F5 key to run the app again.

This will turn on periodic notifications.

Navigate to the Start screen, locate the live tile for the app, and notice that item data is now displayed in the tile.

Next steps

Now that you have created a periodic notification, consider finding out more about the following Mobile Services topics:

Get started with push notificationsPeriodic notifications are managed by Windows and occur only on a predefined schedule. Push notifications can be sent by the mobile service on demand and can be toast, tile, and raw notifications.