CurrentAppSimulator 类

定义

定义用于实例化可用于在测试期间获取模拟许可证信息的对象的方法和属性。

注释

CurrentAppSimulator 类和 Windows 中的其他类型的类型。ApplicationModel.Store命名空间不再使用新功能进行更新。 如果你的项目面向 Windows 10 周年版(10.0;Visual Studio 中的内部版本 14393 或更高版本(即面向 Windows 10 版本 1607 或更高版本),建议改用 Windows.Services.Store 命名空间。 有关详细信息,请参阅应用内购买和试用。 Windows桌面应用程序不支持 CurrentAppSimulator 类,这些应用程序使用 Desktop Bridge 或在 Partner Center(例如, 对于任何与 Xbox Live 集成的游戏,都是如此)。 这些产品必须使用 Windows.Services.Store 命名空间来实现应用内购买和试用。

public ref class CurrentAppSimulator abstract sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class CurrentAppSimulator final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public static class CurrentAppSimulator
Public Class CurrentAppSimulator
继承
Object Platform::Object IInspectable CurrentAppSimulator
属性

Windows 要求

要求 说明
设备系列
Windows 10 (在 10.0.10240.0 中引入)
API contract
Windows.Foundation.UniversalApiContract (在 v1.0 中引入)

注解

在Microsoft Store中列出应用之前,CurrentApp 对象将无法在应用中工作。 开发应用时,使用 CurrentAppSimulator 测试应用的许可和应用内产品。 测试应用后,在将其提交到Microsoft Store之前,必须将 CurrentAppSimulator 的实例替换为 CurrentApp。 如果应用使用 CurrentAppSimulator,则应用将失败认证。

使用 CurrentAppSimulator 时,应用的初始许可状态在名为 WindowsStoreProxy.xml的文件中进行描述。 更改许可证状态的 CurrentAppSimulator 方法(例如,通过购买许可证或处理应用内购买)仅更新内存中对象的许可证状态。 不会更改 WindowsStoreProxy.xml 的内容。 当应用再次启动时,许可证状态将还原为 WindowsStoreProxy.xml中所述的内容。

有关 WindowsStoreProxy.xml 文件的详细信息,请参阅 将 WindowsStoreProxy.xml 文件与 CurrentAppSimulator 配合使用

属性

名称 说明
AppId

获取模拟的应用 ID。 由于 CurrentAppSimulator 仅用于在应用开发期间进行测试,因此返回的 CurrentAppSimulator.AppId 将仅包含 0。

在 Windows 应用商店上列出应用后,CurrentApp.AppId将获取应用载入期间生成的 GUID,并用于在 Windows 应用商店目录中列出应用。

注释

应用更新或更改应用说明不会导致 对 CurrentApp.AppId 进行更改。

LicenseInformation

获取模拟提供的当前应用的模拟许可证元数据。

LinkUri

获取表示当前应用的Microsoft Store列表页的模拟统一资源标识符(URI)。

方法

名称 说明
GetAppPurchaseCampaignIdAsync()

检索当前应用的促销活动 ID。

GetAppReceiptAsync()

创建异步操作,用户可用于模拟请求此应用的所有回执以及任何应用内产品购买。 有关如何使用收据信息的示例,请参阅 使用收据来验证产品购买情况。

GetProductReceiptAsync(String)

创建一个异步操作,用户可用于模拟为指定的产品 ID 请求回执。 有关如何使用收据信息的示例,请参阅 使用收据来验证产品购买情况。

GetUnfulfilledConsumablesAsync()

返回尚未在本地实现的已购买的易耗型应用内产品的列表。

LoadListingInformationAsync()

异步加载模拟应用列表信息。

返回的 ListingInformation 对象包含特定于用户当前所在的市场的列表信息(例如名称、价格、年龄分级)。 此外,还提供了通过应用内产品获取的产品的列表信息。

注释

出于模拟目的,此方法使用 WindowsStoreProxy.xml 文件中的元素作为返回对象的成员的数据源。 有关详细信息,请参阅 CurrentAppSimulator 中的代码示例。

LoadListingInformationByKeywordsAsync(IIterable<String>)

异步加载模拟应用列表信息,并在 ProductListings 集合中返回与所有提供的关键字匹配的应用内产品。

LoadListingInformationByProductIdsAsync(IIterable<String>)

异步加载模拟应用列表信息,并在 ProductListings 集合中返回与任何给定产品 ID 匹配的应用内产品。

ReloadSimulatorAsync(StorageFile)

使用包含 WindowsStoreProxy.xml 文件的 StorageFile 重新加载模拟器。

如果不调用此方法来加载自己的文件,模拟器将创建/加载(但不覆盖)包含一组默认值 的WindowsStoreProxy.xml 文件。

ReportConsumableFulfillmentAsync(String, Guid)

模拟通知Microsoft Store购买易耗型加载项(也称为应用内产品或 IAP)已完成,并且用户有权访问内容。

RequestAppPurchaseAsync(Boolean)

Important

提升的应用程序不支持应用内购买功能。

创建模拟用户请求以购买当前应用的完整许可证的异步操作。

RequestProductPurchaseAsync(String, Boolean)

Important

提升的应用程序不支持应用内购买功能。

注释

[RequestProductPurchaseAsync(String, Boolean) 可能会在Windows 8.1后更改或不可用。 请改用 RequestProductPurchaseAsync(String)。

创建一个异步操作,该操作显示用于模拟从Microsoft Store购买加载项(也称为应用内产品或 IAP)的 UI。

RequestProductPurchaseAsync(String, String, ProductPurchaseDisplayProperties)

Important

提升的应用程序不支持应用内购买功能。

创建一个异步操作,该操作显示用于模拟从Microsoft Store购买加载项(也称为应用内产品或 IAP)的 UI。 此重载包括可用于在应用商店中单个产品条目表示的大型应用内购买目录中显示特定产品/服务的详细信息的参数。

RequestProductPurchaseAsync(String)

Important

提升的应用程序不支持应用内购买功能。

创建一个异步操作,该操作显示用于模拟从Microsoft Store购买加载项(也称为应用内产品或 IAP)的 UI。

适用于

另请参阅