Search code examples
testingin-app-purchaserestorestorekitxcode12

Xcode 12 iOS 14 .storekit restore purchase testing


How do I test restoring a purchase with the new .storekit in Xcode 12? When I call SKPaymentQueue.default().restoreCompletedTransactions(), it goes straight to paymentQueueRestoreCompletedTransactionsFinished(_ queue: SKPaymentQueue) with 0 transaction.

There is not a single mention of "restore" in this 25 minutes WWDC video, nor this documentation article also from Apple, nor in any of the handful tutorials on the Internet. What's even more puzzling to me is I can cannot find any complains/questions regarding this?!

I feel like I have gone mad. It would be great if someone can shed some lights. Thanks in advance!


Solution

  • Just to confirm for people who find this via search: There is no way to unit test restoring purchases via the new Xcode 12 StoreKit Test tools (SKTestSession and related).

    The best you can do (again, as of early 2021) is to test this stuff the old fashioned way:

    1. Make a sandbox purchase
    2. Delete the app off your test device
    3. Reinstall the app
    4. Use your app's restore purchases button
    5. Manually confirm the purchase was restored

    Fingers crossed for WWDC this year...