Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS9 SKPaymentQueue related issue - transaction unexpectedly terminated when app returns to foreground

Transaction Suddenly /Unexpectedly/ Removed from SKPaymentQueue - any ideas why?

Intro

We experience a strange behaviour of SKPaymentQueue under iOS-9 and iOS-9.0.1. We suspect that this is an iOS issue. This example is a minimal app-frame that demonstrates the SKPaymentQueue related issue. Download the example here.

Facts

  • Issue appears in sandbox environment (iOS 9.0.1).
  • Issue appears in TestFlight environment (iOS 9.0.1).
  • Never tested in production environemt.
  • Never tested on iOS 9.1 /beta/.
  • Issue never appears on iOS 8.4.1.

App

This app requires one non-consumable IAP product with content hosted on Apple. App has only one button that starts the transaction/download process.

Issue

Download process is unexpectedly terminated when app is moved from the foreground to the background and then back to the foreground.

To reproduce the issue ...

  1. Adapt this project to your dev. environment (set NON_CONSUMABLE_PRODUCT_WITH_HOSTED_CONTENT to your IAP product-id).

    • Create a test app (iTunes Connect).

    • Host a non-consumable IAP product (Application Loader).

  2. Press the button "Get Product".

  3. Wait until downloading starts.

  4. Press Home button to resign the app.

  5. (Re)Activate the app (touch the app icon).

  6. SKPaymentQueue will eventually send one or two download update events.

  7. !! SKPaymentQueue will send the paymentQueue(queue: SKPaymentQueue, removedTransactions transactions: [SKPaymentTransaction])` message to the observer.

  8. !! Downloading is now terminated (no events).

Known Workarounds

  • Keep the app in the foreground while downloading.

  • Don't activate the app until the downloading is completed (at the system level), then activate the app.

like image 704
orthodog Avatar asked Nov 09 '22 04:11

orthodog


1 Answers

Are you adding the background keys for your app?

You can set them in the info.plist or in capabilities...

  1. info.plist way - Add "fetch" for "UIBackgroundModes"
  2. Go to Capabilities > Background Modes toggle this on. And select the fetch field.

https://developer.apple.com/library/ios/documentation/General/Reference/InfoPlistKeyReference/Articles/iPhoneOSKeys.html#//apple_ref/doc/uid/TP40009252-SW22

like image 133
harmeet07 Avatar answered Nov 14 '22 22:11

harmeet07