How to Create Trial Applications for Windows Phone

Introduction

Windows Phone platform supports applications that run in trial mode. This ability can be used by Windows Phone developers to get users hooked on the application, which provides an opportunity to convert these users to paying customers.

Building applications that support trial mode is very easy with Windows Phone. Moreover there is no need to build two flavors of your application – one for trial mode and one without. You can do with one version that supports both the modes.

Licensing Basics

Whether the application is a trial version or a full version is stored in a license. This license is installed during the process of application installation. Trial licenses do not expire, however, when the user purchases the full version, the license information is updated and the trial license is updated with a full license.

To make the purchase experience easy, Windows Phone framework provides the ability to invoke the marketplace client.

Windows Phone developers can use the LicenseInformation class in the Microsoft.Phone.Marketplace  namespace to check whether the application has a trial license or not.

Hands On

Let us create a Windows Phone demo that supports trial mode. In our mock application, we will offer the ability to play sound for all users and the ability to play FX effects to only the paid version of the trial. Morever, we will also provide the ability for the user to buy the application from the trial version(s) he has downloaded.

Create a new Visual Studio application called WPTrialSample.

Create a new Visual Studio application
Create a new Visual Studio application

When prompted for the target Windows Phone OS version, select WP 7.1 and click OK.

Select the Windows Phone Platform
Select the Windows Phone Platform

Next, add 2 check boxes called "Sound" and "FX effects" and two buttons called "Start" and Purchase."

Include the Microsoft.Phone.Marketplace namespace in our MainPage class.

using Microsoft.Phone.Marketplace;

Next,  create a local variable of class LicenseInformation, which will be used to see if the application is a trial version or not.

public partial class MainPage : PhoneApplicationPage
    {
        static LicenseInformation license = new LicenseInformation();
        // Constructor
        public MainPage()

Next, implement a helper function, which checks whether the license is a trial version or not.

public bool IsFullLicense()
        {
            return !license.IsTrial();
        }

Next, in the constructor, we check for the license information, and if the application is a trial version, we do not enable the "FX Effects" option. This will ensure that in the trial mode, only "sound" option is available. Additionaly, we will enable the Purchase button only if the application is trial mode.

public MainPage()
        {
            InitializeComponent();
            checkBoxFXEffects.IsEnabled = IsFullLicense();
            buttonPurchase.IsEnabled = !IsFullLicense();
        }

Next, we need to implement what action occurs when users click the Purchase button.

We will need to create an instance of the marketplace task and link it here and ask for it to be shown when the application click event is triggered.

If you are having trouble following along, you can download a copy of this exercise below.

If you are running under the emulator, the licensing information will default to full version, So do test your features on a device.

Summary

In this article, we showed how easy it was to use the LicenseInformation class to derive the licensing information. I hope you have found this article useful.

About the Author

Vipul Patel is a Program Manager currently working at Amazon Corporation. He has formerly worked at Microsoft in the Lync team and in the .NET team (in the Base Class libraries and the Debugging and Profiling team). He can be reached at vipul_d_patel@hotmail.com



Related Articles

Downloads

Comments

  • Here Offer The Low Price Gift Online With Good Quality 7e

    Posted by Robggh99 on 03/05/2013 07:01pm

    [p]Well is fairly opposite to the name provided to [url=http://www.airjrodan2013.com]nike air jordan retro[/url] it . It is not stunning Air Max if you remember to consider what on earth is [url=http://www.airjrodan2013.com/air-jordan-12-retro.html]Jordan 12 Retro[/url] happening . Learning them is straightforward with all the right teacher, mastering them requires work (despite the very best teacher) . When seeing nike air jordan [url=http://www.airjrodan2013.com]air jordan release dates 2013[/url] shoe, the felling of your form of extravagancesoon will come to your brains . There茅聢楼忙陋職 positively nothing very [url=http://www.2013sportsshoes.com/air-jordan-13-retro.html]Air Jordan 2012[/url] like a producer new couple of Nike茅聢楼忙陋職 . These words are accomplished at grabbing people's attention and getting these [url=http://www.2013sportsshoes.com/air-jordan-retro-1.html]Jordan Retro 1[/url] to click your link . Leather [url=http://www.airjrodan2013.com/air-jordan-5-retro.html]Jordan 5 Retro[/url] shoes are great for all occasions . 1.[/p]

    Reply
Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Live Event Date: August 20, 2014 @ 1:00 p.m. ET / 10:00 a.m. PT When you look at natural user interfaces as a developer, it isn't just fun and games. There are some very serious, real-world usage models of how things can help make the world a better place – things like Intel® RealSense™ technology. Check out this upcoming eSeminar and join the panel of experts, both from inside and outside of Intel, as they discuss how natural user interfaces will likely be getting adopted in a wide variety …

  • "Security" is the number one issue holding business leaders back from the cloud. But does the reality match the perception? Keeping data close to home, on premises, makes business and IT leaders feel inherently more secure. But the truth is, cloud solutions can offer companies real, tangible security advantages. Before you assume that on-site is the only way to keep data safe, it's worth taking a comprehensive approach to evaluating risks. Doing so can lead to big benefits.

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds