Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When to refresh a receipt vs restore purchases in iOS?

Our iOS app uses in-app purchases, both one-time and an auto-renewing subscription. Both these are non-consumable.

iOS offers two APIs: refresh receipt, and restore completed transactions.

It seems that the latter works for all cases, while the former works in only some cases. Specifically, when we restore an auto-renewable purchase to a new device, restore purchased transactions will cause future renewals to generate a transaction that will be sent in the background to the new device, where as refreshing the receipt will not cause a transaction to be sent to this device the next time there is a renewal.

Given this, is there any reason to use refresh receipt?

Apple seems to say we can use either:

Retrieve information about past purchases by either refreshing the app receipt using the SKReceiptRefreshRequest class or restoring completed transactions using the restoreCompletedTransactions method of the SKPaymentQueue class.

like image 741
yvsbb Avatar asked Aug 10 '17 13:08

yvsbb


People also ask

When should I restore purchases?

If you have multiple devices signed in to the same ‌Apple ID, Restore Purchase will allow you to transfer your in-app purchases to your other devices without having to pay again. For example, if you make an in-app purchase inside an app on your iPhone, you may be able to restore that in-app purchase on your iPad.

What does it mean to restore a purchase on iPhone?

Restoring purchases prevents you from losing all the things that have been purchased on the old devices. All you need to do is sign in with your old Apple ID or Google Account credentials and you would have restored your purchases.

What does restore all purchases mean?

This allows them to regain access to any previously purchased content without paying again. But how can you create the capability and ensure it works across both iOS and Android?

What does clicking Restore purchases do?

Apple requires all apps that support in-app purchases to have a Restore Purchase button. It lets you transfer in-app purchases to other devices (such as a new iPhone).


1 Answers

You need to read this Restoring Purchased Products to understand the purposes between the 2.

From iOS 7, every app downloaded from the store has a receipt (for downloading/buying the app) at appStoreReceiptURL. When users purchases something via In App Purchase, the content at appStoreReceiptURL is updated with purchases information. Most of the cases, you just need to refresh the receipt (at appStoreReceiptURL) so that you know which transactions users have made.

Users restore transactions to maintain access to content they’ve already purchased. For example, when they upgrade to a new phone, they don’t lose all of the items they purchased on the old phone. Include some mechanism in your app to let the user restore their purchases, such as a Restore Purchases button. Restoring purchases prompts for the user’s App Store credentials, which interrupts the flow of your app: because of this, don’t automatically restore purchases, especially not every time your app is launched.

In most cases, all your app needs to do is refresh its receipt and deliver the products in its receipt. The refreshed receipt contains a record of the user’s purchases in this app, on this device or any other device. However, some apps need to take an alternate approach for one of the following reasons:

If you use Apple-hosted content, restoring completed transactions gives your app the transaction objects it uses to download the content. If you need to support versions of iOS earlier than iOS 7, where the app receipt isn’t available, restore completed transactions instead.

Refreshing the receipt asks the App Store for the latest copy of the receipt. Refreshing a receipt does not create any new transactions.

Restoring completed transactions creates a new transaction for every completed transaction the user made, essentially replaying history for your transaction queue observer.

More about receipt, from WWDC 2017, What's new in StoreKit session https://developer.apple.com/videos/play/wwdc2017/303/

enter image description here

You can also watch WWDC 2017, session Advanced StoreKit for more detail https://developer.apple.com/videos/play/wwdc2017/305/

enter image description here

like image 122
onmyway133 Avatar answered Sep 17 '22 08:09

onmyway133