Reputation: 410
This is my first time using Store Kit and everything has gone great up until I attempt to restore purchases. I've seen several other posts on stack overflow about similar issues but I've not found a solution that works for me.
I have a button in my app that calls [[SKPaymentQueue defaultQueue] restoreCompletedTransactions]
. This in turn triggers the SKPaymentTransactionObserver
method paymentQueueRestoreCompletedTransactionsFinished:
. The problem is that paymentQueueRestoreCompletedTransactionsFinished:
has zero transactions in the returned queue.
If I then attempt to make the purchase I am notified that I have already made the purchase. This tells me that the store knows that my test Apple ID has successfully made the purchase on a previous attempt. Why then does paymentQueueRestoreCompletedTransactionsFinished:
return an empty transactions collection on it's queue?
There has been some mention of the sandbox behaving erratically but I need to see this working before I go live to the AppStore.
Any ideas? Am I missing something?
Thanks in advance.
Upvotes: 10
Views: 6010
Reputation: 615
I had this same issue, but instead of creating a new user, I just went to iTunes & Aoo Stores in Settings and logged out of the sandbox test account and tried it again. Working!
Upvotes: 0
Reputation: 359
It depends upon the product type the which products will be queued back in:
-(void)paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue *)queue
as an alternate, read the receipt at:
[[NSBundle mainBundle] appStoreReceiptURL]
only problem with the receipts is that they are stored locally, but apple don't keeps it hanging .. ofcourse the purchases are saved on the apple server too. Refresh / load the receipt by:
SKReceiptRefreshRequest *recreq = [[SKReceiptRefreshRequest alloc] init];
[recreq start];
Upvotes: 0
Reputation: 3065
I believe this is a bug with the sandbox App Store. My restores were not working with my test accounts (created in the iOS 5.0 era). -paymentQueue:updatedTransactions:
was not getting called during a restore.
As suggested by process255's comment, I created a new test user in iTunes Connect. With the new test account, everything works fine!
Upvotes: 8
Reputation: 3947
Are you handling the transactions in -paymentQueue:updatedTransactions:
? This callback gets your restored transactions before the paymentQueueRestoreCompletedTransactionsFinished:
callback.
You should do your restore processing and handling inside -paymentQueue:updatedTransactions:
.
Upvotes: 9