WP8.1 应用程序在调用 RequestProductPurchaseAsync 时崩溃

WP8.1 application crashes on calling RequestProductPurchaseAsync(WP8.1 应用程序在调用 RequestProductPurchaseAsync 时崩溃)

本文介绍了WP8.1 应用程序在调用 RequestProductPurchaseAsync 时崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为 Windows Phone 8.1 (Runtime) 编写 Audio Player,我为 audio 使用 IBackgroundTask.

I'm writing Audio Player for Windows Phone 8.1 (Runtime) and I use IBackgroundTask for audio.

我想使用应用内购买,但调用时应用程序崩溃

I want to use in-app purchase, but applications crashes on calling

var result = await CurrentAppSimulator.RequestProductPurchaseAsync(ProProductId);

没有任何例外.

这个方法在 try-catch 块中被调用.

This method is called within try-catch block.

当应用程序已经通过调用 BackgroundMediaPlayer.Current 启动 IBackgroundTask 时会发生这种情况(在调用 RequestProductPurchaseAsync 几秒钟后发生).

It happens when application already start IBackgroundTask by calling for BackgroundMediaPlayer.Current (happens after few seconds after call RequestProductPurchaseAsync).

如果我在启动应用程序后调用 RequestProductPurchaseAsync 而不调用 BackgroundMediaPlayer.Current,它可以正常工作.

If I call RequestProductPurchaseAsync after start app without calling BackgroundMediaPlayer.Current, it works normally.

这种行为的原因是什么?有一些方法可以解决这个问题吗?

What the reason of this behaviour? There are some ways to solve this problem?

推荐答案

我也遇到了同样的问题,app只是崩溃了,没有抛出异常.发生在 CurrentAppSimulatorCurrentApp 上.

I am having the same problem, app just crashes, no exception thrown. Happens with CurrentAppSimulator as well as CurrentApp.

我想出的唯一解决方案是杀死后台任务

The only solution I came up with was to kill the Backround task

BackgroundMediaPlayer.Shutdown()

在进行 IAP 之前.确保你在调用关机后也放了一点延迟,有时应用程序在没有它的情况下仍然崩溃(但不那么频繁,所以我猜在关机过程中会有一些延迟)

before making the IAP. Make sure you also put in a bit of delay after calling shutdown, sometimes the app still crashed without it (but not as often, so I guess there was some delay during the shutdown process)

这篇关于WP8.1 应用程序在调用 RequestProductPurchaseAsync 时崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:WP8.1 应用程序在调用 RequestProductPurchaseAsync 时崩溃

基础教程推荐