How to check if an add-on has purchased that use StoreContext class

Fei Xue - MSFT 1,111 Reputation points

I have defined a durable AddOn, and when I used RequestPurchaseAsync() method to check if an add-on has purchased or not, it always shows UI which will be annoying to the user.

In the previous version I used: CurrentApp.LicenseInformation.ProductLicenses[ProductId].IsActive to check if the add-on has purchased. So is there any method in StoreContext to solve the problem?

Universal Windows Platform (UWP)
0 comments No comments
{count} votes

Accepted answer
  1. Roy Li - MSFT 32,721 Reputation points Microsoft Vendor


    Welcome to our Microsoft Q&A platform!

    In order to check if an add-on has purchased or not, please check the license information using StoreContext Class. To access the licenses for durable add-ons of the current app for which the user has an entitlement to use, use the AddOnLicenses property of the StoreAppLicense object as follows:

    public async void GetLicenseInfo()  
        if (context == null)  
            context = StoreContext.GetDefault();  
        StoreAppLicense appLicense = await context.GetAppLicenseAsync();  
        if (appLicense == null)  
            textBlock.Text = "An error occurred while retrieving the license.";  
        // Access the valid licenses for durable add-ons for this app.  
        foreach (KeyValuePair item in appLicense.AddOnLicenses)  
            StoreLicense addOnLicense = item.Value;  
            // Use members of the addOnLicense object to access license info  
            // for the add-on.  

    For more information, please refer to this document: Get license info for apps and add-ons.


    0 comments No comments

0 additional answers

Sort by: Most helpful