Windows 8 allows you to build trial functionality right into your existing app, using the LicenseInformation class. Using the methods in this class, you wrap key functionality of your app inside conditional statements. You can then decide to time-limit these features in the trial version, disable them totally, or even include advertising until the user buys the full version. This flexibility ensures you never have to write a second version of your app, or worry about in-app purchases – and your app will always be free to download from the Windows Store.
You can also simulate the current status of your app (trial or full) by using the CurrentAppSimulator class, to test how it will appear to the user.
The current license state of your app is stored as properties of the LicenseInformation class. Typically, you put the functions that depend on the license state in a conditional block, as we describe in the next step. When considering these features, make sure you can implement them in a way that will work in all license states.
Also, decide how you want to handle changes to the app’s license while the app is running. Your trial app can be full-featured, but have in-app ad banners where the paid-for version doesn’t. Or, your trial app can disable certain features, or display regular messages asking the user to buy it.
Think about the type of app you’re making and what a good trial or expiration strategy is for it. For a trial version of a game, a good strategy is to limit the amount of game content that a user can play. For a trial version of a utility, you might consider setting an expiration date, or limiting the features that a potential buyer can use.
For most non-gaming apps, setting an expiration date works well, because users can develop a good understanding of the complete app. Here are a few common expiration scenarios and your options for handling them.
Trial license expires while the app is running
If the trial expires while your app is running, your app can:
- Do nothing.
- Display a message to your customer.
- Prompt your customer to buy the app.
The best practice is to display a message with a prompt for buying the app, and if the customer buys it, continue with all features enabled. If the user decides not to buy the app, close it or remind them to buy the app at regular intervals.
Trial license expires before the app is launched
If the trial expires before the user launches the app, your app won’t launch. Instead, users see a dialog box that gives them the option to purchase your app from the Store.
Customer buys the app while it is running
If the customer buys your app while it is running, here are some actions your app can take.
- Do nothing and let them continue in trial mode until they restart the app.
- Thank them for buying or display a message.
- Silently enable the features that are available with a full-license (or disable the trial-only notices).
If you want to detect the license change and take some action in your app, you must add an event handler for this as described in the next step.
When your app is initializing, get the LicenseInformation object for your app as shown in this example. We assume that licenseInformation is a global variable or field of type LicenseInformation.
Initialize the CurrentApp or CurrentAppSimulator to access the app’s license info. Add an event handler to receive notifications when the license changes while the app is running. The app’s license could change if the trial period expires or the customer buys the app through a Store, for example.
When the license change event is raised, your app must call the License API to determine if the trial status has changed. The code in this step shows how to structure your handler for this event. At this point, if a user bought the app, it is a good practice to provide feedback to the user that the licensing status has changed. You might need to ask the user to restart the app if that’s how you’ve coded it. But make this transition as seamless and painless as possible.
Include code to determine the app’s trial expiration date.
CurrentAppSimulator gets test-specific licensing info from an XML file called "WindowsStoreProxy.xml", located in <installation_folder>\Microsoft\Windows Store\ApiData. If this path and file don’t exist, you must create them, either during installation or at run-time. If you try to access the CurrentAppSimulator.LicenseInformation property without WindowsStoreProxy.xml present in that specific location, you will get an error.
You can edit WindowsStoreProxy.xml to change the simulated expiration dates for your app and for its features. Test all your possible expiration and licensing configurations to make sure everything works as intended.
Be sure to explain how your app will behave during and after the free trial period so your customers won’t be surprised by your app’s behavior.
For more info about describing your app, see Your app’s description
Important Your app must use the CurrentApp object when you submit your app to a Store or it will fail certification.
Trial app and in-app purchase sample