Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Determining license mode in Windows Phone 7 apps

DZone's Guide to

Determining license mode in Windows Phone 7 apps

· Mobile Zone ·
Free Resource

In this post I will show how to separate trial license functionality from full license functionality in Windows Phone 7 applications. Application submitted to a marketplace could be provided with a trial version, so any user can try it before buying.

Additional


Adding a marketplace namespace

Next you need to add a marketplace namespace within MainPage.xaml (or any other xaml file).

using Microsoft.Phone.Marketplace;

Determining a type of license

Now you can determine a type of license (application mode) using the following code:

if (new LicenseInformation().IsTrial())
{
    // trial mode (trial license)
}
else
{
    // full mode
}

Property

Next I would like to share the property I use in my Windows Phone application to determine if application is in trial mode and to simulate the trial mode for emulator. You can modify the boolean value of _emulatorIsTrial variable to switch emulator between trial and full version.

private const bool _emulatorIsTrial = false;
 
public bool IsTrialMode
{
    get
    {
        if (Microsoft.Devices.Environment.DeviceType
               == Microsoft.Devices.DeviceType.Emulator)
        {
            return _emulatorIsTrial;
        }
        return (new LicenseInformation().IsTrial());
    }
}

Source: http://www.eugenedotnet.com/2010/09/w10-determining-license-mode-in-windows-phone-7-apps/


Topics:

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}