Windows 8 Hands-on Experiment Tutorial Experiment 8:windows application Store API

Source: Internet
Author: User
Tags contains visual studio

Hands-on experiment

Lab 8:windows App Store API

September 2012

Brief introduction

One of the most compelling reasons to write Windows Store applications is that you can easily publish them to the Windows store. Given that more than 700 million PCs are currently running Windows 7 worldwide, and each PC represents a potential Windows 8 upgrade, the market and revenue potential is huge and diverse. Given that revenue-sharing programs allocate up to 80% of sales proceeds to authors, developers have a full incentive to write good applications and provide them to users.

The App Store has a flexible profitability option: You can offer trial, one-time purchase, application purchase, third party ecommerce and advertising.

For a trial, you can use the Windows Store API located in the Windows.ApplicationModel.Store namespace to detect whether an application is running on a trial license. Windows Runtime also provides additional APIs to easily upgrade from a trial version to a paid version, retrieve license information, and provide more functionality. The Currentappsimulator class in the Windows runtime provides a convenient way to simulate purchase and test code, depending on the Windows Application store API and all in a controlled environment.

In this experiment you will use the Windows App Store API to make the cookbook of Contoso profitable.

First, you will modify the About box to detect the trial version and include a purchase button if the application is not paid. Then, when the purchase button is clicked, you will use Currentappsimulator to simulate the purchase. Finally, you will be offered a payment instead of a free Italian recipe to simulate the application within the purchase.

Goal

This experiment will show you how to:

Detects if your application is running as a trial version.

Simulate the purchase of applications within applications.

Simulate applications to purchase additional products.

Retrieves license information about applications and products.

System Requirements

You need the following software to complete this experiment:

Microsoft Windows 8

Microsoft Visual Studio 2012

Set up

You must perform the following steps to prepare the computer for this experiment:

1. Install Microsoft Windows 8.

2. Install Microsoft Visual Studio 2012.

Practice

This hands-on experiment includes the following exercises:

1. Test Trial Version

2. Analog Application Purchase

3. Analog Product Purchase

Estimated time of completion of this experiment: 30-40 minutes.

Exercise 1: Test a trial version

In this exercise you will use the Windows Store API in the Windows runtime to customize the Start page content for Contoso Cookbook. If the application has been purchased, you will display the license information. If you have not been purchased (that is, run as a trial version), you will see a purchase button. In addition, the price shown on the purchase button is not written to death, but is from the list information retrieved from the Windows store.

Task to add a license file

We will use the Currentappsimulator class to complete the mock purchase, retrieve license information, and other work. To make the simulation as realistic as possible, we will use a file called License.xml to provide the currentappsimulator with information such as price, expiration date, and so on.

1, open the Contosocookbook project that you completed in experiment 7 in Visual Studio. If you have not completed experiment 7 or want to start with a reference copy, you can find the completed version of the experiment in the start material.

2. If there is no Data folder in the project, the folder is created in Solution Explorer.

3. Right-click the Data folder and use the Add > Existing Item command to import License.xml from the Data folder of the start material.

4, open App.xaml.cs and add the following statement to the Onlaunched method. Place the statement after checking the connection and subscribing to the IF clause of the push notification.

C#

Initialize Currentappsimulator

var file = await Package.Current.InstalledLocation.GetFileAsync ("Data\\license.xml");

Await Windows.ApplicationModel.Store.CurrentAppSimulator.ReloadSimulatorAsync (file);

5, open the License.xml and take some time to check its contents. The <ListingInformation> element contains information about the application itself and the Italian recipe product that we will provide in Exercise 3. <LicenseInformation> contains license information about applications and products. In real life All this information will come from the Windows application store. But in a simulated environment, information comes from Windowsstoreproxy.xml.

See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/net/

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.