I'm adding In App Purchases to one of my apps. As required, I've added a button to let users re-download purchased items. Here is the IBAction method for that:
- (IBAction)touchedButtonUnlockAgain:(id)sender {
[self.activityIndicator startAnimating];
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
[[SKPaymentQueue defaultQueue] restoreCompletedTransactions];
}
When I tap this button, I get the standard login box. I enter my Sandbox username and password (correctly, verified). After that login box disappears, it reappears half a second later. So, I login again with the same username and password (correctly, verified) and THEN the purchases get re-downloaded. I have verified it happens in the Simulator and on a device (iOS 6.0 in both cases).
Why am I getting prompted for my username/password twice?
You can install your paid apps on as many of your devices as you like, so long as they are connected to the Google account used to purchase the apps.
The only reason for this will be unfinished transactions - the ghosts that wait for their finishTransaction
call for redemption. They may exist due to signed-out user initiated transactions that couldn't be finished - or simply due to abrupt app termination before they could finish. Basically, unbalanced calls to addPayment
/ restoreCompletedTransactions
and finishTransaction
can cause them.
Check your delegates: paymentQueue:RestoreCompletedTransactionsFinished:
& paymentQueue:restoreCompletedTransactionsFailedWithError:
Are you doing anything twice? Do you receive any error?
One more thing to check is: When in your app life cycle do you call following statement?
[[SKPaymentQueue defaultQueue] addTransactionObserver]
This is important to be called as early as possible - because sometimes lost transactions that turn ghosts due to app termination appear again - expecting to be finished. Without an active observer, they don't hit updatedTransactions method which is their final gateway to finishTransaction
call.
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