Resources:
Create a trial app for Windows Phone
How to implement a trial experience in a Windows Phone app
Windows Phone 7 Development 31st talk--23rd day: Provide a trial version of the app
Summary of the information:
How to check the trial license in your app:
Add the following two lines in the App.xaml.cs
Using Microsoft.Phone.Marketplace;
Private static LicenseInformation _licenseinfo = new LicenseInformation ();
Use the _licenseinfo.istrial () method, which reads the Istrial property on the LicenseInformation object, returns True when it is a trial version, otherwise a paid version
But actually when debugging, the app's real license information is only available after it is published to the store, so the following two pieces of code are used in App.xaml.cs. After use, the code between # if Debug and #else will be executed when it is debugged, the manual setting is a trial version, and the code between #else and #endif is executed when in release mode. That is, the Istrial property on the LicenseInformation object is read to set whether the trial version.
Private Static BOOL true ; Public BOOL istrial { get { return _istrial; } }
/// <summary> ///Check The current license information for this application/// </summary> Private voidChecklicense () {//When debugging, we want to simulate a trial mode experience. The following conditional allows us to set the _istrial//simulate trial mode being on or off.#ifDEBUGstringMessage ="This is sample demonstrates the implementation of a trial mode in an application."+"Press ' OK ' to simulate trial mode. Press ' Cancel ' to run the application in normal mode."; if(MessageBox.Show (Message,"Debug Trial", Messageboxbutton.okcancel)==Messageboxresult.ok) {_istrial=true; } Else{_istrial=false; }#else_istrial=_licenseinfo.istrial ();#endif }
The app's license needs to be checked when the app starts or resumes:
That is, to add a trial version of the application_launching and application_activated events in App.xaml.cs checklicense()
Use the current app's license information:
Because the Istrial property is set in App.xaml.cs to read the license properties, we can use the (application.current as App). The Istrial property is used to obtain the license information for the app directly, avoiding the reuse of the Istrial () method, which takes 60 milliseconds or more to a typical call.
Create a WP8 trial app