I'm trying to test the in app purchase in my app.
When i restore the in app purchase with a test user who bought the in app purchase it all works fine.
But when i try to restore an in app purchase with a user who didn't make the in app purchase before i expected the framework to call the following method:
-paymentQueue:restoreCompletedTransactionsFailedWithError:
but instead the framework calls:
-paymentQueueRestoreCompletedTransactionsFinished:
like my test user already bought the in app purchase....
Is this the normal behavior? And if so, how do i test a user trying to restore without ever purchasing the in app purchase?
To restore your purchases:Open the drawer from the upper left corner of the screen and select Support. Select Purchases and Paid App from the menu. Tap on the menu option, located in the upper right-hand corner of the screen. Tap on Recover Paid App.
Restoring purchases is a mechanism by which your user can restore their in-app purchases, reactivating any content that had previously been purchased from the same store account (Apple, Google, or Amazon).
See the answer here: iOS in-app-purchase restore returns many transactions
You'll have to handle it in transaction observer.
In short, you start restore process with:
[[SKPaymentQueue defaultQueue] addTransactionObserver:self];
[[SKPaymentQueue defaultQueue] restoreCompletedTransactions];
Then following transaction observer is called:
- (void)paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue *)queue
{
int thisIsTheTotalNumberOfPurchaseToBeRestored = queue.transactions.count;
for (SKPaymentTransaction *transaction in queue.transactions)
{
NSString *thisIsProductIDThatHasAlreadyBeenPurchased = transaction.payment.productIdentifier;
if([thisIsProductIDThatHasAlreadyBeenPurchased isEqualToString:product1ID])
{
//Enable product1 here
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With