Determining license mode in Windows Phone 7 apps
Join the DZone community and get the full member experience.
Join For FreeIn 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
- Creating Trial Applications for Windows Phone (MSDN)
- LicenseInformation Class
-
Managing Trial Applications for Windows Phone 7
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/
Opinions expressed by DZone contributors are their own.
Comments