如何检查有效许可证 (Microsoft Desktop Bridge)

How to check for valid license (Microsoft Desktop Bridge)

我想检查用户是否拥有 Windows Store 应用程序(桌面桥)的有效许可证。起初 StoreLicense.IsActive[1] 属性 看起来很有希望,但文档状态:

This property is reserved for future use, and it is not intended to be used in the current release. Currently, it always returns true.

有趣的是,Microsoft [2] 提供的演示代码也使用了此功能,尽管我可以确认它始终 returns 正确。

检查有效许可证的正确方法是什么?

此致,

[1] https://docs.microsoft.com/de-ch/uwp/api/windows.services.store.storelicense.isactive

[2]https://docs.microsoft.com/en-us/windows/uwp/monetize/implement-a-trial-version-of-your-app

您似乎想检查用户当前是否拥有使用该应用程序的有效许可证,在这种情况下,根据文档 this section 获取应用程序的许可证信息和附加组件

To get license info for the current app, use the GetAppLicenseAsync method. This is an asynchronous method that returns a StoreAppLicense object that provides license info for the app, including properties that indicate whether the user currently has a valid license to use the app (IsActive) and whether the license is for a trial version (IsTrial).

因此,您可以从本文档中使用 StoreAppLicense.IsActive 属性 检查有效的应用程序许可证,而不是目前 StoreLicense.IsActive

更多细节你也可以参考official sample.