This blog post was authored by Thomas Fennel, a program manager on the Windows Phone developer tools team.
Flip, Cycle, and Iconic—you hear them in your sleep calling your name, don’t you? Those are the beautiful Live Tile templates you can use in Windows Phone 8 apps to get deep, personal engagement with your customers. Those new templates have some neat tricks you may not know about, though.
Enter Light Up—an easy way for you to add Windows Phone 8 Live Tile functionality to your Windows Phone OS 7.1 app so that when it’s run on a Windows Phone 7.8 or Windows Phone 8 device it “lights up” the new templates!
Let’s take a second to get our head fully around this concept before we get in to the details. What we’re discussing here is the ability to maintain your existing Windows Phone OS 7.1 app code base and, by adding some conditional code, make that app do new things with Tiles on a Windows Phone 7.8 or 8.0 device. Your Windows Phone OS 7.1 app has always been forward compatible with Windows Phone 7.8 and 8.0, but now it’s forward compatible with additional functionality! When your app is run on a Windows Phone OS 7.1 device, it will behave exactly as it always has, but when someone with a shiny Windows Phone 7.8 update or an entirely new Windows Phone 8.0 device uses it, you can delight them with great new Live Tile features to make the app even more alive. You don’t even need multiple code blocks to deal with differences between APIs in Windows Phone 7.8 and 8.0 because there are none! The code you write works exactly the same way on both Windows Phone 7.8 and Windows Phone 8.0 devices—one code update to rule them all, as it were.
So, what are we really talking about here? In a nutshell: Reflection. Yes, that old chestnut. Rather than just repeating the excellent topic on MSDN, I’ll call out the really important parts here and leave it up to you to follow along with the MSDN article.
- You should use the Windows Phone 8 tools to do your app development. Why? Beyond the fact that the new tools are amazing and make life much easier, it’s because even though you’ll be updating a Windows Phone OS 7.1 app, the Windows Phone 8 tools allow you to deploy that updated app to a Windows Phone 8 emulator. The Windows Phone 8 emulator has the new Tile sizes and templates so that you can test the results of your code.
- To enable the new wide size Tile or set the image for the small size Tile, your default Tile (the one you set up in WMAppManifest.xml) has to be updated at run time by using the ShellTile.Update method with the Flip template, and it can’t change to any other template. I know switching dynamically to something like Cycle or Iconic would be great, but it just wasn’t possible for legacy reasons.
- Secondary Tiles that you create programmatically can be any template (Cycle, Flip, or Iconic).
- On first run of your app, use the ShellTile.Update method and a local image from your XAP package or from the local folder (isostore) to update your default Tile. This ensures a user never sees a blank Tile when they switch to the other sizes, such as small or wide, for the first time. After you’ve done this, use the ShellTile.Update method with remote images. Alternatively, you could use push notifications with remote images, which should work great.
- Using a wide Tile is optional. You can choose to include a wide image in your Tile updates at any time. However, after you do set a wide image, you can’t disable the wide size. This is consistent with Windows Phone 8 apps and use of wide Tiles.
- Add the right thing to your WMAppManifest.xml above the <App> element (yes, AppPlatformVersion=”8.0″ applies to both Windows Phone 7.8 and Windows Phone 8.0). Make sure you don’t change anything about your manifest other than this, otherwise you might break the app’s ability to be submitted to the Windows Phone Store:
- You’ll want to check the version number as your indicator for running your conditional code. MSDN shows how, but basically anything version 7.10.8858 or newer will support the Windows Phone 8 Live Tile templates. If you read better in code, something like this:
That’s pretty much it. All that’s left is to write the code to create or update Tiles. There are examples of that in that MSDN article, and there’s a really great, non-Microsoft endorsed, sponsored or affiliated, community project that makes it much easier here: http://mangopollo.codeplex.com.
Enjoy, and let me know if there’s anything that needs clarification.