简体   繁体   English

什么 UWP API 引发购买事件?

[英]What UWP API raises a purchase event?

I am creating a UWP video editor application centered on the MediaComposition class and I want the user to play with and test it for as long as they want as they would be granted an unlimited free trial upon downloading and installing it.我正在创建一个以 MediaComposition class 为中心的 UWP 视频编辑器应用程序,我希望用户在下载和安装它时可以无限免费试用,只要他们愿意就可以玩和测试它。 (The app will be made available through the Windows Store.) However, any videos produced will have a watermark. (该应用程序将通过 Windows 商店提供。)但是,制作的任何视频都会有水印。 The watermark will be removed as soon as they purchase the app.购买该应用程序后,水印将被删除。

What API will raise a purchase event to help me accomplish this?什么 API 会发起购买活动来帮助我完成此任务?

You may use the StoreContext.OfflineLicensesChanged event from the Windows.Services.Store to detect changes in your app's Microsoft Store license:您可以使用Windows.Services.Store中的StoreContext.OfflineLicensesChanged事件来检测应用的 Microsoft Store 许可证中的更改:

StoreContext.OfflineLicensesChanged Event StoreContext.OfflineLicensesChanged事件

Raised when the status of the app's license changes (for example, the trial period has expired or the user has purchased the full version of the app).当应用程序的许可证状态发生变化时引发(例如,试用期已过或用户已购买应用程序的完整版)。

 public event TypedEventHandler<StoreContext,object> OfflineLicensesChanged;

When this event is raised, you can get the latest app license from the Microsoft Store by calling the GetAppLicenseAsync method.引发此事件时,您可以通过调用GetAppLicenseAsync方法从 Microsoft Store 获取最新的应用许可证。 The StoreAppLicense object returned by this method also contains the latest add-on licenses for the app in the AddOnLicenses property.此方法返回的StoreAppLicense object 还在AddOnLicenses属性中包含应用程序的最新附加许可证。

However, note the following version restriction :但是,请注意以下版本限制

The Windows.Services.Store namespace was introduced in Windows 10, version 1607, and it can only be used in projects that target Windows 10 Anniversary Edition (10.0; Build 14393) or a later release in Visual Studio. Windows.Services.Store命名空间是在 Windows 10 版本 1607 中引入的,它只能用于针对 Windows 10 周年纪念版(10 周年版)或更高版本的项目中。 If your app targets an earlier version of Windows 10, you must use the Windows.ApplicationModel.Store namespace instead of the Windows.Services.Store namespace.如果您的应用面向 Windows 10 的早期版本,则必须使用Windows.ApplicationModel.Store命名空间,而不是Windows.Services.Store命名空间。 For more information, see this article .有关详细信息,请参阅本文

On earlier versions versions, the equivalent event is documented to be the LicenseChanged event in the Windows.ApplicationModel.Store namespace, which has the following additional remark:在早期版本中,等效事件被记录Windows.ApplicationModel.Store命名空间中的LicenseChanged事件,它具有以下附加说明:

LicenseChanged events aren't always immediate. LicenseChanged 事件并不总是立即发生。 If you've registered for the event, the event should fire within an hour;如果您已注册该事件,则该事件应在一个小时内触发; if not, it should occur within 6 hours.如果没有,它应该在 6 小时内发生。 Generally, it's recommended to wait up to 6 hours when testing with CurrentApp , knowing that it will most likely take less time if the app has registered the event.通常,建议在使用CurrentApp进行测试时等待最多 6 小时,因为如果应用程序注册了事件,则很可能需要更少的时间。

See also:也可以看看:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM