首页 > 解决方案 > 如何检查有效许可证(Microsoft Desktop Bridge)

问题描述

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

此属性保留供将来使用,并且不打算在当前版本中使用。目前,它总是返回 true。

有趣的是,Microsoft [2] 提供的演示代码也使用了这个函数,尽管我可以确认它总是返回 true。

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

问候,

[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

标签: windows-store-appswindows-10-universaldesktop-bridge

解决方案


It seems like you want to check whether the user currently has a valid license to use the app, in this case, according to this section of the document Get license info for apps and add-ons:

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).

So that from this document you could use StoreAppLicense.IsActive property to check for valid App licence, not StoreLicense.IsActive currently.

More details you could also reference the official sample.


推荐阅读