Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 231
Fried Rice Avatar asked Oct 09 '20 11:10

Fried Rice


People also ask

How do I enable StoreKit testing in Xcode?

Enable StoreKit Testing in XcodeClick the scheme to open the scheme menu; choose Edit Scheme. In the scheme editor, choose the Run action. Click Options in the action settings. For the StoreKit Configuration option, select a configuration file.

How do I test in app purchases in Testflight?

you can test in-app purchase with test account. then create an account for testing your in app purchase. when test in app purchase try to logout from app store which uses your real account. then it will ask for itunes account while in testing in app purchase then enter your test account credentials.


1 Answers

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...

like image 102
s3cur3 Avatar answered Oct 21 '22 15:10

s3cur3