简体   繁体   中英

When to close restored transactions the user doesn't download

When restoring transactions for non-consumable Apple hosted content, how do you determine when to close the transactions that the user decides not to download at that moment?

Apple suggests this but doesn't explain how:

If your app uses the app receipt and has Apple-hosted content, let the user select which products to restore before starting the restoration process. During restoration, re-download the user-selected content and finish any other transactions immediately.

They seem to imply that you are forcing the user to decide if they would like to download or not download every single item, immediately.

I'd like to instead change the download button to an optional "restore" state that can be pressed whenever the user would like, such as this: (Here's our app with the download button for each downloadable product in a "restore" state.)

这是我们的应用程序,带有处于“恢复”状态的每个可下载产品的下载按钮。

The problem with this implementation is that you aren't closing out the other transactions that the user doesn't want to download.

I tried closing the transactions on the applicationDidEnterBackground method, but the close transaction requests weren't being sent out to Apple.

Is this implementation possible? Thanks for your help.

I stated:

"I tried closing the transactions on the applicationDidEnterBackground method, but the close transaction requests weren't being sent out to Apple."

But that was incorrect. You can close all your open transactions in the App Delegate function, applicationDidEnterBackground .

The following code will close all your restored transactions so your user isn't prompted to login with their Apple ID next time they open your app.

func applicationDidEnterBackground(application: UIApplication) {
    for transaction in SKPaymentQueue.defaultQueue().transactions {
        SKPaymentQueue.defaultQueue().finishTransaction(transaction)
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM