Search code examples
windows-store-appswindows-10-universaldesktop-bridge

How to check for valid license (Microsoft Desktop Bridge)


I want to check if a user has a valid license for a Windows Store application (desktop bridge). At first the StoreLicense.IsActive[1] property looked promising but the docs state:

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

Interestingly the demo code provided by Microsoft [2] also uses this function, although I can confirm that it always returns true.

What is the proper way to check for a valid license?

Regards,

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

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


Solution

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