A nice cool feature in Windows Phone 8 is integration with the lock screen, which means now you can receive app updates while your phone is locked. There is different types of lock screen notifications either to have a quick status update displaying notification icons the same way the Outlook app displays New Mail notifications. You can also change the background image of the lock screen from your app. Finally, you can have a details status update displaying detailed information from the app.

 

P.S.: The lock screen’s app icon, count, and text are pulled directly from the app’s primary Tile. I found that the lock screen does not use the app icon from your primary tile. Instead it uses the a separate 38×38 image in your app, specifically for the lock screen, specified in the manifest file.

 

App Manifest

It’s pretty easy to add this functionality to your app. All what you need is to define a few extensions to let the operating system allow your app to integrate with the lock screen. So here’s what we need to do, open the WMAppManifest.xml file using an XML editor, to do this right click on the WMAppManifest.xml file and select Open With, and use the XML (Text) Editor. First, we need to define the <DeviceLockImageURI> element in the primary token. The DeviceLockImageURI describes which image file to display in the lock screen as an icon. To define DeviceLockImageURI, insert the following element in the <PrimaryToken>

<DeviceLockImageURI IsRelative="true" IsResource="false">Assets\YourLockImage.png</DeviceLockImageURI>

Then, insert the following lines after the between the <Tokens> and <ScreenResolutions> definitions

<Extensions>

  <Extension ExtensionName="LockScreen_Notification_IconCount"

             ConsumerID="{111DFF24-AA15-4A96-8006-2BFF8122084F}"

             TaskID="_default"/>

  <Extension ExtensionName="LockScreen_Notification_TextField"

             ConsumerID="{111DFF24-AA15-4A96-8006-2BFF8122084F}"

             TaskID="_default" />

  <Extension ExtensionName="LockScreen_Background"

             ConsumerID="{111DFF24-AA15-4A96-8006-2BFF8122084F}"

             TaskID="_default" />

</Extensions>

 

Lock Screen Settings

Before the app can display notifications you need to configure the Lock Screen settings to allow the type of notification that you are interested in displaying. Currently an app can display 3 types of notifications: background image; detailed status; and quick status, as mentioned above.


To configure the device to display notifications from your app, go to the settings app and select Lock screen

settings_thumb[1]

In the lock screen settings, choose the notification type that will display notifications from our app

image_thumb[6]

Testing on the Emulator

 


To test on the Windows Phone emulator you can use the Simulation Dashboard which integrates directly into Visual Studio. To launch this, go to Tools –> Simulation Dashboard. You can use this tool to Lock and Unlock the emulator to test your apps lock screen integration.

image_thumb[1]

P.S.: you can also activate the lock screen, by pressing F12 while the emulator is running.