c# – 使用CurrentAppSimulator进行应用内购买开发测试
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了c# – 使用CurrentAppSimulator进行应用内购买开发测试,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1634字,纯文字阅读大概需要3分钟。
内容图文
我已经使用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();
}
编辑:在访问这些属性之前,我使用以下命令在Debug模式下初始化CurrentAppSimulator:
StorageFolder proxyDataFolder = await Package.Current.InstalledLocation.GetFolderAsync("Assets");
StorageFile proxyFile = await proxyDataFolder.GetFileAsync("test-purchase.xml");
await CurrentAppSimulator.ReloadSimulatorAsync(proxyFile);
在test-purchase.xml的底部,我得到了:
<LicenseInformation>
<App>
<IsActive>true</IsActive>
<IsTrial>false</IsTrial>
</App>
<Product ProductId="premium">
<IsActive>false</IsActive>
</Product>
</LicenseInformation>
内容总结
以上是互联网集市为您收集整理的c# – 使用CurrentAppSimulator进行应用内购买开发测试全部内容,希望文章能够帮你解决c# – 使用CurrentAppSimulator进行应用内购买开发测试所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。