Defines methods and properties used to instantiate an object that you can use to get simulated license info during testing.
Note You must replace the CurrentAppSimulator class with the CurrentApp class before you submit the app to the Windows Store. Apps that use the CurrentAppSimulator will fail certification.
Syntax
var currentAppSimulator = Windows.ApplicationModel.Store.CurrentAppSimulator;
Attributes
- MarshalingBehaviorAttribute(Agile)
- StaticAttribute(Windows.ApplicationModel.Store.ICurrentAppSimulator, NTDDI_WIN8)
- ThreadingAttribute(Both)
- VersionAttribute(NTDDI_WIN8)
Members
The CurrentAppSimulator class has these types of members:
Methods
The CurrentAppSimulator class has these methods. With C#, Visual Basic, and C++, it also inherits methods from the Object class.
| Method | Description |
|---|---|
| GetAppReceiptAsync | Creates the async operation that the user can use to simulate requesting all receipts for this app and any in-app purchases. |
| GetProductReceiptAsync | Creates the async operation that the user can use to simulate requesting the receipt for the productId specified. |
| LoadListingInformationAsync | Loads the simulated app listing information asynchronously. Implements the IAsyncInfo interface. |
| ReloadSimulatorAsync | Reloads the simulator using a StorageFile containing the WindowsStoreProxy.xml file. |
| RequestAppPurchaseAsync | Creates the async operation that enables the user to simulate the purchase of a full license for the current app. |
| RequestProductPurchaseAsync | Creates the async operation that displays the UI that is used to simulate the purchase of a product or feature from the Windows Store. |
Properties
The CurrentAppSimulator class has these properties.
| Property | Access type | Description |
|---|---|---|
| Read-only | Gets a simulated app ID. | |
| Read-only | Gets the simulated license metadata for the current app as provided by the simulation. | |
| Read-only | Gets the simulated Uniform Resource Identifier (URI) that represents a Windows Store listing page for the current app. |
Remarks
Until the app has been listed in the Windows Store, the CurrentApp object won't work in the app. Use the CurrentAppSimulator to test your app's licensing and in-app purchases while you develop your app. After you test your app and before you submit it to the Windows Store, replace the instances of CurrentAppSimulator with CurrentApp. Your app will fail certification if it uses CurrentAppSimulator.
Note When using the simulation, the initial licensing state of the app is described in WindowsStoreProxy.xml. CurrentAppSimulator method that alter the license state, for example by buying a license or handling an in-app purchase, only update the license state of the object in memory. The contents of WindowsStoreProxy.xml are not changed. When the app starts again, the license state reverts to what is described in WindowsStoreProxy.xml.
The CurrentAppSimulator object gets its data from the WindowsStoreProxy.xml file in the %userprofile%\appdata\local\packages\<package-moniker>\localstate\microsoft\Windows Store\Apidata folder. You must configure this file for the scenario that you want to simulate in the CurrentAppSimulator properties.
The contents of this file are defined by the SimulatedCurrentApp.xsd file included as an example later in this topic, and they reflect the organization of the objects and properties of the Windows.ApplicationModel.Store namespace.
The elements of this file are included in the CurrentApp root node and include:
-
ListingInformation
Represents data that would normal be found in the app's listing and includes these elements:
-
App
Represents data about the app and contains these elements:
-
AppId
The GUID that identifies the app in the store. This can be any GUID for testing.
-
LinkUri
The URI of the listing page in the store. This can be any valid URI for testing.
-
AgeRating
An integer that represents the minimum age rating of the app. This is the same value you would specify in the Dashboard when you submit the app. The values used by the Windows Store are: 3, 7, 12, and 16.
-
CurrentMarket
This is the customer's country/region.
For each country/region in which the app is listed, there must be a MarketData element.
-
MarketData
Info about the app for this country/region.
Requires the xml:lang attribute, which specifies the country/region for which this info applies.
-
Name
The name of the app in this country/region.
-
Description
The description of the app for this country/region.
-
Price
The price of the app in this country/region.
-
CurrencySymbol
The currency symbol used in this country/region.
-
-
-
Product
Describes a product or a feature in this app that is enabled when the customer makes an in-app purchase.
Requires the ProductId attribute, which contains the string used by the app to identify the product or feature.
Requires the LicenseDuration attribute, which contains the number of days the license will be valid after the purchase. The expiration date of the new license created by a product purchase is the purchase date plus the license duration.
-
MarketData
Info about the product or feature for this country/region.
Requires the xml:lang attribute, which specifies the country/region for which this information applies.
-
Name
The name of the product or feature in this country/region.
-
Price
The price of the product or feature in this country/region.
-
CurrencySymbol
The currency symbol used in this country/region.
-
CurrencyCode
The currency code used in this country/region.
-
-
-
LicenseInformation
Represents data that describes the licenses available for this app and includes the following elements:
-
App
Describes the app's license:
-
IsActive
Describes the current license state of this app.
true indicates the license is valid. Normally this value is true, whether the app has a trial mode or not.
false indicates an invalid license. Set this value to false to test how your app behaves when it has an invalid license.
-
IsTrial
Describes the current trial state of this app.
true indicates the app is being used during the trial period.
false indicates the app is not in a trial, either because the app has been purchased or the trial period has expired.
-
ExpirationDate
The date the trial period for this app expires. The date must be express as: yyyy-mm-ddThh:mm:ss.ssZ. For example, 05:00 on January 19, 2012 would be specified as 2012-01-19T05:00:00.00Z.
If this element is required when IsTrial is true. Otherwise, it is not required.
-
DefaultResponse
Describes the default error code returned by a given method. The MethodName attribute allows you to specify one of these methods:
- RequestAppPurchaseAsync_GetResult
- RequestProductPurchaseAsync_GetResult
- LoadListingInformationAsync_GetResult
-
-
Product
Describes the license status of a product or feature in the app:
-
IsActive
Describes the current license state of this product or feature.
true indicates the product or feature can be used.
false indicates the product or feature cannot be used or has not been purchased.
-
ExpirationDate
The date the product or feature expires. The date must be express as: yyyy-mm-ddThh:mm:ss.ssZ. For example, 05:00 on January 19, 2012 would be specified as 2012-01-19T05:00:00.00Z.
If this element is present, the product or feature has an expiration date.
If this element is not present, the product or feature does not expire.
-
-
-
Simulation
Describes how various method calls work. When the SimulationMode attribute is set to Automatic, the methods will automatically return the specified HRESULT error codes. This can be used when running automated test cases.
Examples
This example is a WindowsStoreProxy.xml file that describes an app with a trial mode that expires at 05:00 (Z) on Jan. 19, 2012.
<?xml version="1.0" encoding="UTF-16"?> <CurrentApp> <ListingInformation> <App> <AppId>2B14D306-D8F8-4066-A45B-0FB3464C67F2</AppId> <LinkUri>http://apps.windows.microsoft.com/app/2B14D306-D8F8-4066-A45B-0FB3464C67F2</LinkUri> <CurrentMarket>en-US</CurrentMarket> <AgeRating>3</AgeRating> <MarketData xml:lang="en-us"> <Name>Trial management full license</Name> <Description>Sample app for demonstrating trial license management</Description> <Price>4.99</Price> <CurrencySymbol>$</CurrencySymbol> </MarketData> </App> </ListingInformation> <LicenseInformation> <App> <IsActive>true</IsActive> <IsTrial>true</IsTrial> <ExpirationDate>2012-01-19T05:00:00.00Z</ExpirationDate> </App> </LicenseInformation> <Simulation SimulationMode="Automatic"> <DefaultResponse MethodName="LoadListingInformationAsync_GetResult" HResult="E_FAIL"/> </Simulation> </CurrentApp>
The next example is a WindowsStoreProxy.xml file that describes an app that has been purchased and has a feature that expires at 05:00 (Z) on Jan. 19, 2012.
<?xml version="1.0" encoding="utf-16" ?> <CurrentApp> <ListingInformation> <App> <AppId>988b90e4-5d4d-4dea-99d0-e423e414ffbc</AppId> <LinkUri>http://apps.windows.microsoft.com/app/988b90e4-5d4d-4dea-99d0-e423e414ffbc</LinkUri> <CurrentMarket>en-us</CurrentMarket> <AgeRating>3</AgeRating> <MarketData xml:lang="en-us"> <Name>Expiring in-app feature</Name> <Description>App description text goes here.</Description> <Price>5.99</Price> <CurrencySymbol>$</CurrencySymbol> </MarketData> </App> <Product ProductId="feature1" LicenseDuration="10"> <MarketData xml:lang="en-us"> <Name>Feature 1</Name> <Price>1.99</Price> <CurrencySymbol>$</CurrencySymbol> </MarketData> </Product> </ListingInformation> <LicenseInformation> <App> <IsActive>true</IsActive> <IsTrial>false</IsTrial> </App> <Product ProductId="feature1"> <IsActive>true</IsActive> <ExpirationDate>2012-01-19T00:00:00.00Z</ExpirationDate> </Product> </LicenseInformation> </CurrentApp>
SimulatedCurrentApp.xsd
The next example is the XSD file that defines the structure of the temporary files used to test your app with the CurrentAppSimulator.
<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:import namespace="http://www.w3.org/XML/1998/namespace" />
<xs:element name="CurrentApp" type="CurrentAppDefinition"></xs:element>
<xs:complexType name="CurrentAppDefinition">
<xs:sequence>
<xs:element name="ListingInformation" type="ListingDefinition" minOccurs="1" maxOccurs="1"/>
<xs:element name="LicenseInformation" type="LicenseDefinition" minOccurs="1" maxOccurs="1"/>
<xs:element name="Simulation" type="SimulationDefinition" minOccurs="0" maxOccurs="1"/>
</xs:sequence>
</xs:complexType>
<xs:simpleType name="ResponseCodes">
<xs:restriction base="xs:string">
<xs:enumeration value="S_OK">
<xs:annotation>
<xs:documentation>0x00000000</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="E_INVALIDARG">
<xs:annotation>
<xs:documentation>0x80070057</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="E_CANCELLED">
<xs:annotation>
<xs:documentation>0x800704C7</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="E_FAIL">
<xs:annotation>
<xs:documentation>0x80004005</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="E_OUTOFMEMORY">
<xs:annotation>
<xs:documentation>0x8007000E</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="ERROR_ALREADY_EXISTS">
<xs:annotation>
<xs:documentation>0x800700B7</xs:documentation>
</xs:annotation>
</xs:enumeration>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="StoreMethodName">
<xs:restriction base="xs:string">
<xs:enumeration value="RequestAppPurchaseAsync_GetResult" id="RPPA" />
<xs:enumeration value="RequestProductPurchaseAsync_GetResult" id="RFPA" />
<xs:enumeration value="LoadListingInformationAsync_GetResult" id="LLIA" />
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="SimulationMode">
<xs:restriction base="xs:string">
<xs:enumeration value="Interactive" />
<xs:enumeration value="Automatic" />
</xs:restriction>
</xs:simpleType>
<xs:complexType name="ListingDefinition">
<xs:sequence>
<xs:element name="App" type="AppListingDefinition" />
<xs:element name="Product" type="ProductListingDefinition" minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="AppListingDefinition">
<xs:sequence>
<xs:element name="AppId" type="xs:string" minOccurs="1" maxOccurs="1" />
<xs:element name="LinkUri" type="xs:anyURI" minOccurs="1" maxOccurs="1" />
<xs:element name="CurrentMarket" type="xs:language" minOccurs="1" maxOccurs="1" />
<xs:element name="AgeRating" type="xs:unsignedInt" minOccurs="1" maxOccurs="1" />
<xs:element name="MarketData" type="MarketSpecificAppData" minOccurs="1" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="MarketSpecificAppData">
<xs:sequence>
<xs:element name="Name" type="xs:string" minOccurs="1" maxOccurs="1" />
<xs:element name="Description" type="xs:string" minOccurs="1" maxOccurs="1" />
<xs:element name="Price" type="xs:float" minOccurs="1" maxOccurs="1" />
<xs:element name="CurrencySymbol" type="xs:string" minOccurs="1" maxOccurs="1" />
<xs:element name="CurrencyCode" type="xs:string" minOccurs="0" maxOccurs="1" />
</xs:sequence>
<xs:attribute ref="xml:lang" use="required" />
</xs:complexType>
<xs:complexType name="MarketSpecificProductData">
<xs:sequence>
<xs:element name="Name" type="xs:string" minOccurs="1" maxOccurs="1" />
<xs:element name="Price" type="xs:float" minOccurs="1" maxOccurs="1" />
<xs:element name="CurrencySymbol" type="xs:string" minOccurs="1" maxOccurs="1" />
<xs:element name="CurrencyCode" type="xs:string" minOccurs="0" maxOccurs="1" />
</xs:sequence>
<xs:attribute ref="xml:lang" use="required" />
</xs:complexType>
<xs:complexType name="ProductListingDefinition">
<xs:sequence>
<xs:element name="MarketData" type="MarketSpecificProductData" minOccurs="1" maxOccurs="unbounded" />
</xs:sequence>
<xs:attribute name="ProductId" use="required">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="100"/>
<xs:pattern value="[^,]*"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="LicenseDuration" type="xs:integer" use="optional" />
</xs:complexType>
<xs:complexType name="LicenseDefinition">
<xs:sequence>
<xs:element name="App" type="AppLicenseDefinition" />
<xs:element name="Product" type="ProductLicenseDefinition" minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="AppLicenseDefinition">
<xs:sequence>
<xs:element name="IsActive" type="xs:boolean" minOccurs="1" maxOccurs="1" />
<xs:element name="IsTrial" type="xs:boolean" minOccurs="1" maxOccurs="1" />
<xs:element name="ExpirationDate" type="xs:dateTime" minOccurs="0" maxOccurs="1" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="ProductLicenseDefinition">
<xs:sequence>
<xs:element name="IsActive" type="xs:boolean" minOccurs="1" maxOccurs="1" />
<xs:element name="ExpirationDate" type="xs:dateTime" minOccurs="0" maxOccurs="1" />
</xs:sequence>
<xs:attribute name="ProductId" type="xs:string" use="required" />
</xs:complexType>
<xs:complexType name="SimulationDefinition" >
<xs:sequence>
<xs:element name="DefaultResponse" type="DefaultResponseDefinition" minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
<xs:attribute name="SimulationMode" type="SimulationMode" use="optional" />
</xs:complexType>
<xs:complexType name="DefaultResponseDefinition">
<xs:attribute name="MethodName" type="StoreMethodName" use="required" />
<xs:attribute name="HResult" type="ResponseCodes" use="required" />
</xs:complexType>
</xs:schema>
Requirements
|
Minimum supported client | Windows 8 [Windows Store apps only] |
|---|---|
|
Minimum supported server | Windows Server 2012 [Windows Store apps only] |
|
Namespace |
|
|
Metadata |
|
See also
Build date: 2/25/2013