您可以使用 Windows.ApplicationModel.Store 命名空間中的成員,將應用程式內購買和試用版功能新增至您的通用 Windows 平台 (UWP) 應用程式,以協助您的應用程式創造營收。 這些 API 也能讓您存取應用程式授權資訊。
本節中的文章針對數個常見案例使用 Windows.ApplicationModel.Store 命名空間中的成員提供深入的指引和程式碼範例。 如需 UWP 應用程式內購買相關基本概念的概觀,請參閱應用程式購買和試用版。 如需示範如何使用 Windows.ApplicationModel.Store 命名空間實作試用版和應用程式內購買的完整範例,請參閱市集範例。
重要
Windows.ApplicationModel.Store 命名空間不再使用新功能更新。 如果您的專案在 Visual Studio 中以 Windows 10 年度版 (10.0;組建 14393) 或更新版本為目標 (也就是說,您是以 Windows 10 版本 1607 或更新版本為目標),建議您改用 Windows.Services.Store 命名空間。 如需詳細資訊,請參閱應用程式內購買和試用版。 Windows.ApplicationModel.Store 命名空間在使用傳統型橋接器 的 Windows 傳統型應用程式中,或在合作夥伴中心使用開發沙箱的應用程式或遊戲中 (例如,這是指任何與 Xbox Live 整合的遊戲) 並不受支援。 這些產品必須使用 Windows.Services.Store 命名空間來實作應用程式內購買和試用版。
開始使用 CurrentApp 和 CurrentAppSimulator 類別
Windows.ApplicationModel.Store 命名空間的主要進入點是 CurrentApp 類別。 這個類別提供的靜態屬性和方法可讓您用來取得目前應用程式及其可用附加元件的資訊,取得目前應用程式或其附加元件的授權資訊,為目前使用者購買應用程式或附加元件,以及執行其他工作。
CurrentApp 類別會從 Microsoft Store 取得其資料,因此您必須擁有開發人員帳戶,且應用程式必須在市集中發佈,才能在應用程式中成功使用此類別。 將應用程式提交至市集之前,您可以使用名為 CurrentAppSimulator 的模擬版本來測試程式碼。 測試應用程式之後,以及提交至 Microsoft Store 之前,您必須將 CurrentAppSimulator 的例項取代為 CurrentApp。 如果您的應用程式使用 CurrentAppSimulator,則認證將會失敗。
使用 CurrentAppSimulator 時,應用程式授權和應用程式內產品的初始狀態會在名為 WindowsStoreProxy.xml 的開發電腦上於本機檔案中描述。 如需此檔案的詳細資訊,請參閱搭配 CurrentAppSimulator 使用 WindowsStoreProxy.xml 檔案。
如需您可以使用 CurrentApp 和 CurrentAppSimulator 執行之一般工作的詳細資訊,請參閱下列文章。
主題 | 描述 |
---|---|
在試用版本中排除或限制某些功能 | 如果您讓客戶在試用期間免費使用您的應用程式,您可以藉由排除或限制試用期間的某些功能,吸引客戶升級至應用程式的完整版本。 |
啟用應用程式內產品購買 | 無論您的應用程式是否免費,都可以直接從應用程式內銷售內容、其他應用程式或新的應用程式功能 (例如解除鎖定遊戲的下一個關卡)。 在這裡,我們會示範如何在您的應用程式中啟用這些產品。 |
啟用消耗性 App 內產品購買 | 透過市集商務平台提供消耗性應用程式內產品 (提供可以再次購買、使用及購買的項目),為客戶提供健全且可靠的購買體驗。 這對於可以購買的遊戲內貨幣 (金幣、硬幣等),之後用於特定道具等事項特別有用。 |
管理大型應用程式內產品目錄 | 如果您的應用程式提供大型應用程式內產品目錄,您可以選擇遵循本主題所述的程序,以協助管理您的目錄。 |
使用收據驗證產品購買情況 | 促成成功購買產品的每個 Microsoft Store 交易都可以選擇傳回交易收據,該收據會為客戶提供上市產品的相關資訊和貨幣成本。 對於您的應用程式需要確認使用者已購買您的應用程式,或已從 Microsoft Store 進行應用程式內產品購買,存取這項資訊可支援這些情況。 |
搭配 CurrentAppSimulator 使用 WindowsStoreProxy.xml 檔案
使用 CurrentAppSimulator 時,應用程式授權和應用程式內產品的初始狀態會在名為 WindowsStoreProxy.xml 的開發電腦上於本機檔案中描述。 更改應用程式的狀態 (例如購買授權或處理應用程式內購買) 的 CurrentAppSimulator 方法,只會更新記憶體中 CurrentAppSimulator 物件的狀態。 WindowsStoreProxy.xml 的內容不會變更。 當應用程式再次啟動時,授權狀態會還原為 WindowsStoreProxy.xml 中所述的內容。
WindowsStoreProxy.xml 檔案預設會建立在下列位置:%UserProfile%\AppData\Local\Packages\<應用程式套件資料夾>\LocalState\Microsoft\Windows Store\ApiData。 您可以編輯此檔案,以定義您想要在 CurrentAppSimulator 屬性中模擬的案例。
雖然您可以修改此檔案中的值,但建議您建立自己的 WindowsStoreProxy.xml 檔案 (在 Visual Studio 專案的資料資料夾中),改供 CurrentAppSimulator 使用。 模擬交易時,呼叫 ReloadSimulatorAsync 以載入您的檔案。 如果您未呼叫 ReloadSimulatorAsync 來載入您自己的 WindowsStoreProxy.xml 檔案,CurrentAppSimulator 會建立/載入 (但不會覆寫) 預設 WindowsStoreProxy.xml 檔案。
注意
請注意,CurrentAppSimulator 要等到 ReloadSimulatorAsync 完成之後,才會完全初始化。 而且,由於 ReloadSimulatorAsync 是非同步方法,因此應該小心避免在一個執行緒上初始化 CurrentAppSimulator,同時在另一個執行緒上進行查詢的競爭狀況。 其中一種方法是使用旗標來指出初始化已完成。 從 Microsoft Store 安裝的應用程式必須使用 CurrentApp 而不是 CurrentAppSimulator,在此情況下,不會呼叫 ReloadSimulatorAsync,因此剛才提及的競爭情況不適用。 基於這個理由,請設計您的程式碼,使其能在非同步和同步兩種情況下運作。
範例
此範例是一個 WindowsStoreProxy.xml 檔案 (UTF-16 編碼),描述在 2015 年 1 月 19 日 05:00 (UTC) 到期之試用版模式的應用程式。
<?xml version="1.0" encoding="UTF-16"?>
<CurrentApp>
<ListingInformation>
<App>
<AppId>00001111-aaaa-2222-bbbb-3333cccc4444</AppId>
<LinkUri>http://apps.windows.microsoft.com/app/00001111-aaaa-2222-bbbb-3333cccc4444</LinkUri>
<CurrentMarket>en-US</CurrentMarket>
<AgeRating>3</AgeRating>
<MarketData xml:lang="en-us">
<Name>App with a trial 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>2015-01-19T05:00:00.00Z</ExpirationDate>
</App>
</LicenseInformation>
<Simulation SimulationMode="Automatic">
<DefaultResponse MethodName="LoadListingInformationAsync_GetResult" HResult="E_FAIL"/>
</Simulation>
</CurrentApp>
下一個範例是一個 WindowsStoreProxy.xml 檔案 (UTF-16 編碼),描述一個已購買的應用程式,具有一項在 2015 年 1 月 19 日 05:00 (UTC) 到期的功能,並且有消耗性應用程式內購買。
<?xml version="1.0" encoding="utf-16" ?>
<CurrentApp>
<ListingInformation>
<App>
<AppId>11112222-bbbb-3333-cccc-4444dddd5555</AppId>
<LinkUri>http://apps.windows.microsoft.com/app/11112222-bbbb-3333-cccc-4444dddd5555</LinkUri>
<CurrentMarket>en-us</CurrentMarket>
<AgeRating>3</AgeRating>
<MarketData xml:lang="en-us">
<Name>App with several in-app products</Name>
<Description>Sample app for demonstrating an expiring in-app product and a consumable in-app product</Description>
<Price>5.99</Price>
<CurrencySymbol>$</CurrencySymbol>
</MarketData>
</App>
<Product ProductId="feature1" LicenseDuration="10" ProductType="Durable">
<MarketData xml:lang="en-us">
<Name>Expiring Item</Name>
<Price>1.99</Price>
<CurrencySymbol>$</CurrencySymbol>
</MarketData>
</Product>
<Product ProductId="consumable1" LicenseDuration="0" ProductType="Consumable">
<MarketData xml:lang="en-us">
<Name>Consumable Item</Name>
<Price>2.99</Price>
<CurrencySymbol>$</CurrencySymbol>
</MarketData>
</Product>
</ListingInformation>
<LicenseInformation>
<App>
<IsActive>true</IsActive>
<IsTrial>false</IsTrial>
</App>
<Product ProductId="feature1">
<IsActive>true</IsActive>
<ExpirationDate>2015-01-19T00:00:00.00Z</ExpirationDate>
</Product>
</LicenseInformation>
<ConsumableInformation>
<Product ProductId="consumable1" TransactionId="00000001-0000-0000-0000-000000000000" Status="Active"/>
</ConsumableInformation>
</CurrentApp>
結構描述
本節列出定義 WindowsStoreProxy.xml 檔案結構的 XSD 檔案。 若要在使用 WindowsStoreProxy.xml 檔案時,將此結構描述套用至 Visual Studio 中的 XML 編輯器,請執行下列動作:
- 在 Visual Studio 中開啟 WindowsStoreProxy.xml 檔案。
- 在 [XML] 功能表上,按一下 [建立結構描述]。 這會根據 XML 檔案的內容建立暫時的 WindowsStoreProxy.xsd 檔案。
- 以下列結構描述取代該 .xsd 檔案的內容。
- 將檔案儲存到您可以將它套用至多個應用程式專案的位置。
- 切換至 Visual Studio 中的 WindowsStoreProxy.xml 檔案。
- 在 [XML] 功能表上,按一下 [結構描述],然後在 WindowsStoreProxy.xsd 檔案清單中找出資料列。 如果檔案的位置不是您想要的位置 (例如,如果仍然顯示暫存檔),按一下 [新增]。 瀏覽至正確的檔案,然後按一下 [確定]。 您現在應該會在清單中看到該檔案。 請確定核取記號出現在該結構描述的 [使用] 資料行中。
完成此動作之後,對 WindowsStoreProxy.xml 所做的編輯將受限於該結構描述。 如需詳細資訊,請參閱如何:選取要使用的 XML 結構描述。
<?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="ConsumableInformation" type="ConsumableDefinition" minOccurs="0" 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="ConsumableStatus">
<xs:restriction base="xs:string">
<xs:enumeration value="Active"/>
<xs:enumeration value="PurchaseReverted"/>
<xs:enumeration value="PurchasePending"/>
<xs:enumeration value="ServerError"/>
</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:enumeration value="ReportConsumableFulfillmentAsync_GetResult" id="RPFA"/>
<xs:enumeration value="LoadListingInformationByKeywordsAsync_GetResult" id="LLIKA"/>
<xs:enumeration value="LoadListingInformationByProductIdAsync_GetResult" id="LLIPA"/>
<xs:enumeration value="GetUnfulfilledConsumablesAsync_GetResult" id="GUC"/>
<xs:enumeration value="GetAppReceiptAsync_GetResult" id="GARA"/>
</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="ConsumableDefinition">
<xs:sequence>
<xs:element name="Product" type="ConsumableProductDefinition" 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:element name="Description" type="xs:string" minOccurs="0" maxOccurs="1"/>
<xs:element name="Tag" type="xs:string" minOccurs="0" maxOccurs="1"/>
<xs:element name="Keywords" type="KeywordDefinition" minOccurs="0" maxOccurs="1"/>
<xs:element name="ImageUri" type="xs:anyURI" 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:attribute name="ProductType" type="xs:string" use="optional"/>
</xs:complexType>
<xs:simpleType name="guid">
<xs:restriction base="xs:string">
<xs:pattern value="[\da-fA-F]{8}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{12}"/>
</xs:restriction>
</xs:simpleType>
<xs:complexType name="ConsumableProductDefinition">
<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="TransactionId" type="guid" use="required"/>
<xs:attribute name="Status" type="ConsumableStatus" use="required"/>
<xs:attribute name="OfferId" type="xs:string" 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:attribute name="OfferId" type="xs:string" use="optional"/>
</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:complexType name="KeywordDefinition">
<xs:sequence>
<xs:element name="Keyword" type="xs:string" minOccurs="0" maxOccurs="10"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
元素和屬性描述
本節描述 WindowsStoreProxy.xml 檔案中的元素和屬性。
這個檔案的根元素是 CurrentApp 元素,代表目前的應用程式。 此元素包含下列子元素:
元素 | 必要 | 數量 | 描述 |
---|---|---|---|
ListingInformation | 是 | 1 | 包含來自應用程式清單的資料。 |
LicenseInformation | 是 | 1 | 描述此應用程式及其耐久性附加元件可用的授權。 |
ConsumableInformation | 否 | 0 或 1 | 描述此應用程式可用的消耗性附加元件。 |
模擬 | 否 | 0 或 1 | 描述在測試期間呼叫各種 CurrentAppSimulator 方法如何在應用程式中運作。 |
ListingInformation 元素
此元素包含來自應用程式清單的資料。 ListingInformation 是 CurrentApp 元素的必要子系。
ListingInformation 包含下列子元素。
元素 | 必要 | 數量 | 描述 |
---|---|---|---|
應用程式 | 是 | 1 | 提供應用程式的相關資料。 |
產品 | 否 | 0 或更多 | 描述應用程式的附加元件。 |
App 元素 (ListingInformation 的子系)
此元素描述應用程式的授權。 App 是 ListingInformation 元素的必要子系。
App 包含下列子元素。
元素 | 必要 | 數量 | 描述 |
---|---|---|---|
AppId | 是 | 1 | 在市集中識別應用程式的 GUID。 對於測試,這可以是任何 GUID。 |
LinkUri | 是 | 1 | 市集中清單頁面的 URI。 對於測試,這可以是任何有效的 URI。 |
CurrentMarket | 是 | 1 | 客戶的國家/地區。 |
AgeRating | 是 | 1 | 整數,代表應用程式的最低年齡分級。 當您提交應用程式時,會在合作夥伴中心指定這個值。 市集所使用的值為:3、7、12 和 16。 如需這些分級的詳細資訊,請參閱年齡分級。 |
MarketData | 是 | 1 或多個 | 包含指定國家/地區之應用程式的相關資訊。 針對列出應用程式的每個國家/地區,您必須包含 MarketData 元素。 |
MarketData 元素 (App 的子系)
此元素提供指定國家/地區之應用程式的相關資訊。 針對列出應用程式的每個國家/地區,您必須包含 MarketData 元素。 MarketData 是 App 元素的必要子系。
MarketData 包含下列子元素。
元素 | 必要 | 數量 | 描述 |
---|---|---|---|
名稱 | 是 | 1 | 此國家/地區中的應用程式名稱。 |
描述 | 是 | 1 | 此國家/地區之應用程式的描述。 |
Price | 是 | 1 | 此國家/地區中的應用程式價格。 |
CurrencySymbol | 是 | 1 | 此國家/地區所使用的貨幣符號。 |
CurrencyCode | 否 | 0 或 1 | 此國家/地區所使用的貨幣代碼。 |
MarketData 具有下列屬性。
屬性 | 必要 | 描述 |
---|---|---|
xml:lang | 是 | 指定市場資料資訊適用的國家/地區。 |
Product 元素 (ListingInformation 的子系)
此元素描述應用程式的附加元件。 Product 是 ListingInformation 元素的選擇性子系,其中包含一或多個 MarketData 元素。
Product 具有下列屬性。
屬性 | 必要 | 描述 |
---|---|---|
ProductId | 是 | 包含應用程式用來識別附加元件的字串。 |
LicenseDuration | 否 | 指出在購買項目之後,授權的有效天數。 產品購買所建立之新授權的到期日是購買日期加上授權持續時間。 只有當 ProductType 屬性是 Durable 時,才會使用這個屬性;消耗性附加元件會忽略這個屬性。 |
ProductType | 否 | 包含值,可識別應用程式內產品的持續性。 支援的值為 Durable (預設值) 和 Consumable 值。 針對耐久性類型,Product 元素會在 LicenseInformation 底下描述其他資訊;針對消耗性類型,Product 元素會在 ConsumableInformation 底下描述其他資訊。 |
MarketData 元素 (Product 的子系)
此元素提供指定國家/地區之附加元件的相關資訊。 針對列出附加元件的每個國家/地區,您必須包含 MarketData 元素。 MarketData 是 Product 元素的必要子系。
MarketData 包含下列子元素。
元素 | 必要 | 數量 | 描述 |
---|---|---|---|
名稱 | 是 | 1 | 此國家/地區中的附加元件名稱。 |
Price | 是 | 1 | 此國家/地區中的附加元件價格。 |
CurrencySymbol | 是 | 1 | 此國家/地區所使用的貨幣符號。 |
CurrencyCode | 否 | 0 或 1 | 此國家/地區所使用的貨幣代碼。 |
描述 | 否 | 0 或 1 | 此國家/地區之附加元件的描述。 |
標籤 | 否 | 0 或 1 | 附加元件的自訂開發人員資料 (也稱為標籤)。 |
關鍵字 | 否 | 0 或 1 | 包含最多 10 個 Keyword 元素,其中包含附加元件的關鍵字。 |
ImageUri | 否 | 0 或 1 | 附加元件清單中影像的 URI。 |
MarketData 具有下列屬性。
屬性 | 必要 | 描述 |
---|---|---|
xml:lang | 是 | 指定市場資料資訊適用的國家/地區。 |
LicenseInformation 元素
此元素描述此應用程式及其耐久性應用程式內產品的授權。 LicenseInformation 是 CurrentApp 元素的必要子系。
LicenseInformation 包含下列子元素。
元素 | 必要 | 數量 | 描述 |
---|---|---|---|
應用程式 | 是 | 1 | 描述應用程式的授權。 |
產品 | 否 | 0 或更多 | 描述應用程式中耐久性附加元件的授權狀態。 |
下表顯示如何結合 App 和 Product 元素下的值來模擬一些常見狀況。
要模擬的狀況 | IsActive | IsTrial | ExpirationDate |
---|---|---|---|
完整授權 | true | false | 不存在。 它實際上可能存在並指定未來的日期,但建議您省略 XML 檔案中的元素。 如果存在並指定過去的日期,則會忽略 IsActive,並將其視為 false。 |
在試用期間 | true | true | <未來的日期時間> 這個元素必須存在,因為 IsTrial 為 true。 您可以造訪顯示目前國際標準時間 (UTC) 的網站,以了解要將此時間設定在多久的未來,以取得您想要的剩餘試用期間。 |
到期的試用版 | false | true | <過去的日期時間> 這個元素必須存在,因為 IsTrial 為 true。 您可以造訪顯示目前國際標準時間 (UTC) 的網站,以了解在 UTC 何時是「過去」。 |
無效 | false | false | <任何值或已省略> |
App 元素 (LicenseInformation 的子系)
此元素描述應用程式的授權。 App 是 LicenseInformation 元素的必要子系。
App 包含下列子元素。
元素 | 必要 | 數量 | 描述 |
---|---|---|---|
IsActive | 是 | 1 | 描述此應用程式的目前授權狀態。 值 true 表示授權有效;false 表示授權無效。 此值通常為 true,無論應用程式是否具有試用模式。 將此值設定為 false,以測試當應用程式具有無效授權時的行為。 |
IsTrial | 是 | 1 | 描述此應用程式目前的試用版狀態。 值 true 表示正在試用期間使用應用程式;false 表示應用程式不在試用中,可能是因為已購買應用程式或試用期間已過期。 |
ExpirationDate | 否 | 0 或 1 | 此應用程式的試用期到期日期,以國際標準時間 (UTC) 表示。 日期必須依此表示:yyyy-mm-ddThh:mm:ss.ssZ。 例如,2015 年 1 月 19 日 05:00 會指定為 2015-01-19T05:00:00.00Z。 IsTrial 為 true 時,需要此元素。 否則就不需要。 |
Product 元素 (LicenseInformation 的子系)
此元素描述應用程式中耐久性附加元件的授權狀態。 Product 是 LicenseInformation 元素的選擇性子系。
Product 包含下列子元素。
元素 | 必要 | 數量 | 描述 |
---|---|---|---|
IsActive | 是 | 1 | 描述此附加元件的目前授權狀態。 值 true 表示可以使用附加元件;false 表示無法使用或尚未購買附加元件 |
ExpirationDate | 否 | 0 或 1 | 附加元件到期的日期,以國際標準時間 (UTC) 表示。 日期必須依此表示:yyyy-mm-ddThh:mm:ss.ssZ。 例如,2015 年 1 月 19 日 05:00 會指定為 2015-01-19T05:00:00.00Z。 如果這個元素存在,附加元件會有到期日。 如果不存在,附加元件就不會過期。 |
Product 具有下列屬性。
屬性 | 必要 | 描述 |
---|---|---|
ProductId | 是 | 包含應用程式用來識別附加元件的字串。 |
OfferId | 否 | 包含應用程式用來識別附加元件所屬類別的字串。 這提供對大型專案目錄的支援,如管理大型應用程式內產品目錄中所述。 |
Simulation 元素
此元素描述在測試期間呼叫各種 CurrentAppSimulator 方法如何在應用程式中運作。 Simulation 是 CurrentApp 元素的選擇性子系,其中包含零個或多個 DefaultResponse 元素。
Simulation 具有下列屬性。
屬性 | 必要 | 描述 |
---|---|---|
SimulationMode | 否 | 值可以是 Interactive 或 Automatic。 當此屬性設定為 Automatic 時,方法會自動傳回指定的 HRESULT 錯誤碼。 執行自動化測試案例時,可以使用此功能。 |
DefaultResponse 元素
這個元素描述 CurrentAppSimulator 方法傳回的預設錯誤碼。 DefaultResponse 是 Simulation 元素的選擇性子系。
DefaultResponse 具有下列屬性。
屬性 | 必要 | 描述 |
---|---|---|
MethodName | 是 | 將此屬性指派給結構描述中 StoreMethodName 型別所顯示的其中一個列舉值。 每個列舉值都代表一個您想要在測試期間模擬應用程式中的錯誤碼傳回值的 CurrentAppSimulator 方法。 例如,值 RequestAppPurchaseAsync_GetResult 指出您想要模擬 RequestAppPurchaseAsync 方法的錯誤碼傳回值。 |
HResult | 是 | 將此屬性指派給結構描述中 ResponseCodes 型別所顯示的其中一個列舉值。 每個列舉值都代表您要針對指派給這個 DefaultResponse 元素之 MethodName 屬性的方法傳回的錯誤碼。 |
ConsumableInformation 元素
此元素描述此應用程式可用的消耗性附加元件。 ConsumableInformation 是 CurrentApp 元素的選擇性子系,可以包含零個或多個 Product 元素。
Product 元素 (ConsumableInformation 的子系)
此元素描述消耗性附加元件。 Product 是 ConsumableInformation 元素的選擇性子系。
Product 具有下列屬性。
屬性 | 必要 | 描述 |
---|---|---|
ProductId | 是 | 包含應用程式用來識別消耗性附加元件的字串。 |
TransactionId | 是 | 包含應用程式透過履行程序用來追蹤消耗性產品之購買交易的 GUID (以字串的形式)。 請參閱啟用消耗性應用程式內產品購買。 |
狀態 | 是 | 包含應用程式用來指出消耗性產品履行狀態的字串。 值可以是 Active、PurchaseReverted、PurchasePending 或 ServerError。 |
OfferId | 否 | 包含應用程式用來識別消耗性產品所屬類別的字串。 這提供對大型專案目錄的支援,如管理大型應用程式內產品目錄中所述。 |