2017-02-23 33 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

回答