0

我想In App Purchase的API(C++/CX)和RequestProductPurchaseAsync拋出Platform::InvalidArgumentException^RequestProductPurchaseAsync拋出平臺:: InvalidArgumentException^

我有以下代碼:

// loading store 
create_task(CurrentAppSimulator::LoadListingInformationAsync()).then([](ListingInformation^ listing) 
{ 
    auto product1 = listing->ProductListings->Lookup("product1"); 
    auto product2 = listing->ProductListings->Lookup("product2"); 
}); 

//after that finishes I try to purchase product2 
auto licenseInformation = CurrentAppSimulator::LicenseInformation; 
if (!licenseInformation->ProductLicenses->Lookup("product2")->IsActive) 
{ 
// this exact next line throws InvalidArgumentException 
auto op = CurrentAppSimulator::RequestProductPurchaseAsync("product2", true); // throws !!!!! 
auto purchaseTask = create_task(op); 

purchaseTask.then([](task<Platform::String^> currentTask) 
    { 
     ... 
    }); 
} 
else ... 

這完全相同的代碼工作如果它在Windows Store示例項目中使用,但它不適用於我自己的項目。 (顯然與假貨xml文件相同)。

任何人都可以看看嗎?謝謝:)

回答

0

我發現解決方案:所有的WinRT存儲函數都必須在UI線程中調用,所以從UI線程獲取CoreDispatcher並讓它通過它來調用這些函數。

相關問題