Search code examples
c#crashwindows-phonein-app-purchasewindows-phone-8.1

WP8.1 application crashes on calling RequestProductPurchaseAsync


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);

without any exceptions.

This method is called within try-catch block.

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

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?


Solution

  • 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()
    

    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)