Windows 8 Metro design and development-Windows application store (2)

Source: Internet
Author: User
Buy a simulated application

You can useWindowsstoreproxy. xmlModify the user interface based on whether the application is a trial version. However, the actual purchase behavior cannot be simulated. In this exercise, you need to write an event for the purchase button.ProgramIn this way, you canWindowsThe app is purchased in the app store.

Task1-InAbout. jsAdd purchaseCode

To simulate the purchase behavior of an application, we need to callCurrentappsimulator. requestapppurchaseasync. To check the successful arrangement of purchase behaviors, we need to handleLicensechangedEvent.

Note:RequestpurchaseappasyncMethod to submit a slaveWindowsThe app store purchases the app's asynchronous request. To determine when (whether) the application is successfully purchased, you need to listenLicensechangedEvent. When this event is triggered, you can checkCurrentappsimulator. licenseinformation. istrialTo confirm whether the purchase is successful.

1.OpenAbout. js.

2.In theIf (App. licenseinformation. istrial)At the end of the clauseElseBefore the statement, add the following statement:

Javascript

// Handle licensechanged events

App. licenseinformation. onlicensechanged = function (){

If (! App. licenseinformation. istrial ){

VaR dialog = newwindows. UI. popups. messagedialog ("Thanks for purchasing contosocookbook! ");

Dialog. showasync ();

}

};

 

// Handle clicks of the purchase button

Button. onclick = function (){

App. requestapppurchaseasync ();

};

 

 

Task2-Purchase applications

Simple, right? Now simulate the purchase behavior of the application. Please note that,CurrentappsimulatorStore the purchase and license status modification information in the memory, and do not store the information inWindowsstoreproxy. xml. Therefore, after purchasing an application, as long as the application is still running,Purchased(Paid) "status, and once restarted, It is restored to the trial version status.

1.PressF5Enable the application.

2.Open"About"Page, click the Buy button to simulate the application purchase behavior.

3.InWindowsIn the App Store dialog box, click"Continue"Button to complete the simulated purchase behavior.

4.Confirm3Confirm that the purchase is successful.



Figure3

Message confirming successful purchase

5.Display"About"Page, confirm that the purchase button has disappeared.

Note:Before purchasingContosocookbookLater, it does not provide additional features for users; it just uses license information to replace the purchase button. In real-world applications, you can select to restrict user functions in the trial version. The full function is provided only after the purchase.

6.ReturnVisual StudioAnd stop debugging.

Note: ThisArticleThis is the script for Windows 8 online lab on msdn. It is for your reference only. If you want to experience the complete experiment, click the msdn online lab below

Http://msdn.microsoft.com/zh-cn/hh968278

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.