How to Send Live Tile Notifications in Windows Store Apps

Working with Tile notifications in Windows Store apps is pretty easy. Check out this blog post and download and play with a great example from MSDN. Now, how do you send live tile notifications in your Windows Store apps? You can send tile notifications when something happens in your app, e.g. when the setting is changed by user, or you can send updates periodically, e.g. every 15 minutes, when the app is running in the background on a lock screen.

Sending Live Tiles When Settings Are Changed

One simple example is to send an update when the source file of a video player or the video player volume is changed. In my quick demo, I use the Video Player. To add tile notification function to the app, add the NotificationsExtentions project from the tile example, and one line of code to call the method, SendTile. See sample code below.

// Users can resize tiles to square or wide. // Apps can choose to include only square assets (meaning the app's tile can never be wide), or // include both wide and square assets (the user can resize the tile to square or wide). // Apps cannot include only wide assets.

// Apps that support being wide should include square tile notifications since users // determine the size of the tile.

In this scenario, you will need to run the app as a background task and place it on the lock screen. You can find more info on background tasks here. You can download and test a background task sample app here.

In order to place an app on the lock screen, you call the BackgroundExecutionManager.RequestAccessAsync method in your app. Below is sample code from a lock screen app.

BackgroundAccessStatus status = await BackgroundExecutionManager.RequestAccessAsync(); switch (status) { case BackgroundAccessStatus.AllowedWithAlwaysOnRealTimeConnectivity: rootPage.NotifyUser("This app is on the lock screen and has access to Always-On Real Time Connectivity.", NotifyType.StatusMessage); break; case BackgroundAccessStatus.AllowedMayUseActiveRealTimeConnectivity: rootPage.NotifyUser("This app is on the lock screen and has access to Active Real Time Connectivity.", NotifyType.StatusMessage); break; case BackgroundAccessStatus.Denied: rootPage.NotifyUser("This app is not on the lock screen.", NotifyType.StatusMessage); break; case BackgroundAccessStatus.Unspecified: rootPage.NotifyUser("The user has not yet taken any action. This is the default setting and the app is not on the lock screen.", NotifyType.StatusMessage); break; default: break; } }

Note that Tile updates are sent in the same manner as updates sent to the tile on the Start screen, but are limited to text only and must be wide templates.

Alternatively, you can register the task of sending Tile updates and schedule to run the task every 15 minutes by using BackgroundTaskBuilder and TimeTrigger.