If you want to monetize your UWP apps, it might be part of you plan to have some kind of trial so that uses can try out the basic functionality of your hard work. This can be achieved in two places, firstly you need to test and set the properties in the app. Then you need to change the properties of your app submission in the Windows Dev Center. So here I will cover how we write the code to test for a trial installation of your app.
In my MoonPhase app, I have limited some functionality in the trial version. Basically a user can view the current details on the Moon, but if they want to move forward or backwards in time to see what the Moon looks like on different days, then a message popups up to tell them they cannot do that in the trial. This way they get to use the basic functionality and if they find the app useful, then they can pay for the full version in the app store.
Trial Functionality in UWP
The ‘message’ element is a div in the HTML that the fly out will append to when the ‘previous’ button is clicked.
So to test locally simply pass in true.
var licenseInformation = getLicenseInfo(true);
The CurrentAppSimulator will then look for the WindowsStoreProxy.xml file that resides on your drive, usually somewhere like this:-
%UserProfile%\AppData\Local\Packages\<app package folder>\LocalState\Microsoft\Windows Store\ApiData\WindowsStoreProxy.xml
Depending on what you are testing for, you can populate the sections you need. I am testing for a trail version, so set the IsTrial within the App element to true. You can now run the app in the debugger and you can step through your code to see what paths it is taking. In my case I show the message fly out notifying the user of the trial status.
One thing to remember though is to take out the Boolean or set to false before submitting to the store. I am still looking for a better way to handle this and was hoping there would be some sort of pre-processor functionality like what is used in C# that could be switched when in debug mode.
Submitting Through the Windows Dev Center
So once you are happy to publish the app and the Boolean has been taken out or set correctly, go to the ‘Pricing and availability’ section of your submission.
The use the drop down to set the trial period.
When a user first installs the app in trial mode the real IsTrial property will be set to true and each time the app launches it will check the install date and if this is still set to true then the app won’t launch and the user will be presented with a Windows dialog to prompt them to purchase from the store. When they do purchase, then the IsTrial is set to false and they get all the functionality.