The ListingInformation.ProductListings object has a different interface when deployed to the Windows Store

The CurrentAppSimulator class is useful for exploring licensing information for your Windows Store app.  Once you are done testing you can change the class name to CurrentApp with confidence that your app will perform correctly when deployed to the Windows Store.  There can be a subtle problem if you do not closely follow our sample code for using the ProductListing object because it is an object with a different interface when you change from CurrentAppSimulator to CurrentApp.

You will notice that the following code works fine for the CurrentAppSimulator version but will fail for the CurrentApp class at the .hasKey() call:

function tryProduct1() {
     var licenseInformation = currentApp.licenseInformation;
     if (licenseInformation.productLicenses.hasKey("product1").isActive) {
         WinJS.log && WinJS.log("You can use Product 1.", "sample", "status");
     } else {
         WinJS.log && WinJS.log("You don't own Product 1. You must buy Product 1 before you can use it.", "sample", "error");
     }
  }

The reason is revealed by looking at the productListing or productLicenses object using the debugger. 

From CurrentApp:

ProductListings   type:   System.Collections.Generic.IReadOnlyDictionary<string,Windows.ApplicationModel.Store.ProductListing>

From CurrentAppSimulator:

productListings  type:   Windows.Foundation.Collections.IMapView`2 String,Windows.ApplicationModel.Store.ProductListing>

 

The CurrentAppSimulator is a different type and supports .hasKey, but the CurrentApp does not.

 

The good news is if you use our sample code you would simply use this code instead, which works with both objects:

if (licenseInformation.productLicenses.lookup("product1").isActive) {
 

Let me know if this helps you in anyway!

-Jeff