0 Comments

While building my apps for WP7 that users will pay for, I like to create a trial so the users can try out my app before they buy it. But when you are debugging your app there is no Trial simulation. So Looking on the web I found one.

Here is what i do to simulate trial mode in my Windows Phone 7 apps.

First at the top of your App.xaml.cs file add this

*EDIT*
I forgot to put this in here at the top. You need it to access the licence information.

 

//Used to determine if app is running under a trail license.

private static LicenseInformation _licenseInfo = new LicenseInformation();

and to use that you will need to add in the folling using statment.

 

using Microsoft.Phone.Marketplace;

*END EDIT*

 

private static bool _isTrial = true;

public bool IsTrial

{

get

{

return _isTrial;

}

}

I usually add that in right under my RootFrame property.

I then create a method in my App.xaml.cs

private void CheckLicense()

{

#if DEBUG

if (MessageBox.Show("This is for debugging purposes. This allows trial mode to be set. Press 'OK' to simulate trial mode. Press 'Cancel' to run the application in normal mode.", "Debug Trial",

MessageBoxButton.OKCancel) == MessageBoxResult.OK)

{

_isTrial = true;

}

else

{

_isTrial = false;

}

#else

_isTrial = _licenseInfo.IsTrial();

#endif

}

I then put the CheckLicence method into my Application_Launching and Application_Activated methods in my App.xaml.cs file to check if the application is bought or a trial version.

Then in your code you set up what will happen in your trial version and all you have to is check the IsTrial if true, it is a trail version. If false it is a full/paid version.

 

if ((Application.Current as App).IsTrial)

{

//Do trial things in here

}

I hope this helps you out creating your WP7 app!