Har*_*rry 4 c# microsoft-metro windows-runtime
我已经使用CurrentAppSimulator设置了应用内购买,并设置了获取应用内购买的功能.我也(可能)配置了我的WindowsStoreProxy.xml文件来处理这个问题.
但是,当我购买插件并给它一个S_OK返回值时,它仍然说IAP处于非活动状态.我可以将其激活的唯一方法是手动编辑WindowsStoreProxy.xml文件并将Active属性设置为Active.这看起来很奇怪,因为来自Microsoft的Store示例工作正常.我看不出他们有什么不同 - 他们仍然使用这种CurrentAppSimulator.RequestProductPurchaseAsync()方法.我在哪里错了...?
首先,我使用自己的类CurrentAppProxy,它在调试模式下使用CurrentAppSimulator,在Release中使用CurrentApp.然后我使用此代码购买InApp购买,它工作得很好:
try
{
await CurrentAppProxy.RequestProductPurchaseAsync(PremiumName, false);
// after closing the inApp purchase dialog, test, if it was bought
if (licenseInformation.ProductLicenses[PremiumName].IsActive)
{
// set the local flag
IsPremium = true;
dialog = new MessageDialog(resourceLoader.GetString("ThanksForPremium"));
await dialog.ShowAsync();
}
// else do not show anything
}
catch (Exception)
{
// failed buying the premium
dialog = new MessageDialog(resourceLoader.GetString("ErrorBuyingPremium"));
dialog.ShowAsync();
}
Run Code Online (Sandbox Code Playgroud)
编辑:在访问这些属性之前,我使用以下命令在Debug模式下初始化CurrentAppSimulator:
StorageFolder proxyDataFolder = await Package.Current.InstalledLocation.GetFolderAsync("Assets");
StorageFile proxyFile = await proxyDataFolder.GetFileAsync("test-purchase.xml");
await CurrentAppSimulator.ReloadSimulatorAsync(proxyFile);
Run Code Online (Sandbox Code Playgroud)
在test-purchase.xml的底部,我得到了:
<LicenseInformation>
<App>
<IsActive>true</IsActive>
<IsTrial>false</IsTrial>
</App>
<Product ProductId="premium">
<IsActive>false</IsActive>
</Product>
</LicenseInformation>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1661 次 |
| 最近记录: |