If you are developing for Windows Phone 7, and planning on publishing to the marketplace it is a good idea to support a trial mode of your product. You will get a much wider audience if you support trial than if you don’t, Microsoft themselves said they found it increased sales and drove further demand. In this post I am going to discuss how I went about implementing IsTrial following the Microsoft best practices, how I setup my development environment to make it extremely easy to switch between testing my game in trial mode and paid mode and other best practices to follow.
First and foremost, when using IsTrial() you should be aware of the Microsoft best practices as follows are some generalized ones:
- Do not rely on usage time limited trials to protect your application’s value.
Typically, it is best to protect the value of your full mode application by limiting trial access to key code paths. A user may uninstall and retry an application without restriction so a trial design that offers full mode behavior for a limited time provides only inconvenience as a barrier to reuse. - Cache license state if you check trial state frequently.
Note that the IsTrial() and the Guide.IsTrialMode methods are designed to be event-driven. A typical call takes approximately 60 milliseconds or more. - Check the IsTrial() state when your application loads or resumes.
You can avoid some potential trial design flaws especially if you cache the IsTrial() state. - Provide a way for users to buy your trial application before the end-of-trial.
- Make sure that you help users understand why they want to buy your application, perhaps, by implementing your trial limit at a point in the application where they will naturally want more.
For example, let users experience the first level of game play and require them to purchase the application to play higher levels, retain points, or to connect to a gaming service.
See the Microsoft site for more details.
One of the most important things to pay attention to here is where they state you should “Cache the IsTrial() state..”, since each call to IsTrial() could take up to 60 milliseconds if you call this in a loop or if you call this method often it could potentially affect performance of your application. It may also cause your application to fail certification if they later enforce restrictions on calling this method a number of times.
For instance in my applicaiton Hanoi, I call IsTrial() one time on startup, and one time on resume. That’s it, the rest of the time I am reading a cached value and I have found this to be extremely useful. Here is how I have implemented my version of a Cached version IsTrial().
Here is the following code snippet for how to set it up in your App.cs:
public partial class App : Application {
public static bool IsTrial = true;
private static void LoadIsTrial()
{
IsTrial = new LicenseInformation().IsTrial();
#if DEBUG_TRIAL
IsTrial = true;
#endif
}
private void Application_Launching(object sender, LaunchingEventArgs e)
{
LoadIsTrial();
}
private void Application_Activated(object sender, ActivatedEventArgs e)
{
LoadIsTrial();
}
}
Now in my opinion, this is very elegant because to access the cached variable all you need to do is App.IsTrial and you are accessing the cached version of IsTrial instead of calling the method, and you are guaranteed to have an up to date value. Next as you may have noticed is I have some #if #endif statements in their, which is what makes debugging this a breeze, also note that when this gets compiled in release mode anything inside those lines will get optimized out of the final code, so theres no chance it will ever run. I also assumed the IsTrial cached version is equal to True, I do this to play it safe in the event that something does go wrong the user will get the benefit of the doubt.
Below is how to setup Visual Studio so you can easily switch between Trial and Paid:
Note: If you are walking through you may notice I have already setup mine called “Debug_Trial”, just ignore that and follow along with the screen shots.
The first thing you need to do is open up the Configuration Manager in Visual Studio, so click on the drop down where it says “Debug” or “Release” and click “Configuration Manager”
Next, in the configuration manager there is another drop down listing all of the Active Solution Configurations, click on “<New…>”
Next, change the “Copy settings from:” drop down to “Debug” or “Release” whichever one you are creating. If you are creating a profile to test IsTrial in debug mode than select debug and vice versa, then give it a name. I chose Debug_Trial.
Last but least, since this probably the most important step. Go to the properties of your project, click the “Configuration” drop down and select the configuration you just created. Then paste into the “Conditional compilation symbols” box “DEBUG_TRIAL” as it appears above, make sure there is a space between SILVERLIGHT and no leading space.
Now when you need to test your Trial mode, just go to the configuration menu select the “Debug_Trial” and then hit F5 or click Run. If you want to test the paid, just change it to “Debug” and do the same. This is the easiest way to implement this that I have found. Requires nearly zero code, and once you have this setup you never have to touch it again!
Related posts:






