2017-02-23 43 views
1

我现在用的是下面这段代码在我UWP-JS应用检查应用程序内的购买是否有效:UWP:无法访问LicenseInformation

(function() { 
    // Initialization 
    // var store_app = Windows.ApplicationModel.Store.CurrentApp; 
    var store_app = Windows.ApplicationModel.Store.CurrentAppSimulator; 
    var licenseInformation = store_app.licenseInformation; 

    // Check for Product 
    if (licenseInformation.productLicenses["product1"].isActive) { 
     // do something 
    } else {}; 
})(); 

当我调试这个我得到了以下错误5号线:

0x803d0000 - JavaScript runtime error: The input data was not in the expected format or did not have the expected value.

我下面这个Documentation

我在做什么错?

+0

您正在复制C#示例代码,但未能将其转换为JS。在JS中,属性是camelCase。 'if(licenseInformation.productLicenses [“product1”]。isActive)''。有关更多详细信息,请参阅[Windows Store JS示例应用程序](https://github.com/Microsoft/Windows-universal-samples/blob/win10-1507/Samples/Store/js/js/scenario2-inAppPurchase.js#L44 )。 –

+0

另一种可能性是您的XML有一个不正确的ExpirationDate。它的格式应该是' 2016-01-01T00:00:00.00Z'。 –

+0

@RaymondChen谢谢你的提示!这并不能解决这个错误。我应该在哪里指定到期日期? – jonhue

回答