ios - IAP restore state firing incorrectly -
i have restore button on iap screen, after passing apple submission , going live, friend tested on device, when did able restore purchase without ever having made purchase in first place, when debug code have noticed hitting restore runs completion delegate method, in turn runs method unlock functionality.
- (void)paymentqueuerestorecompletedtransactionsfinished:(skpaymentqueue *)queue
my code follows:
#pragma mark restore purchases #pragma mark - -(void)restorepurchaseiap{ // inquire restore [[skpaymentqueue defaultqueue] restorecompletedtransactions]; } #pragma mark skpaymenttransactionobserver #pragma mark - -(void)paymentqueue:(skpaymentqueue *)queue updatedtransactions:(nsarray *)transactions { (skpaymenttransaction *transaction in transactions) { switch (transaction.transactionstate) { case skpaymenttransactionstatepurchased: [[skpaymentqueue defaultqueue] finishtransaction:transaction]; [delegate itempurchased]; break; case skpaymenttransactionstatefailed: [delegate itempurchasedfailed]; [[skpaymentqueue defaultqueue]finishtransaction:transaction]; break; case skpaymenttransactionstaterestored: nslog(@"restored state"); [[skpaymentqueue defaultqueue]finishtransaction:transaction]; break; default: break; } } } #pragma mark skpaymenttransactionobserver #pragma mark - - (void)paymentqueuerestorecompletedtransactionsfinished:(skpaymentqueue *)queue{ nslog(@"restored state completed"); [delegate purchaserestored]; } -(void)paymentqueue:(skpaymentqueue *)queue restorecompletedtransactionsfailedwitherror:(nserror *)error{ nslog(@"restore has failed"); }
this occurs if not logged in user business relationship apple. noticed first time debugged on friends device if tried create purchase, cancelled when prompted iap cost , confirmation, restore button restore purchase.
am right in thinking when phone call restorecompletedtransactions, apple should confirm , run the:
- (void)paymentqueuerestorecompletedtransactionsfinished:(skpaymentqueue *)queue{
method if iap has been purchased, or supposed doing check pack somewhere?
the documentation paymentqueuerestorecompletedtransactionsfinished
states
tells observer payment queue has finished sending restored transactions.
discussion
this method called after restorable transactions have been processed payment queue. application not required in method.
so method indicates no more restoration transactions sent (this may after 0 restoration transactions sent in case of no transactions restore or not logged in).
you cannot determine state of purchases in method, not valid unlock functionality based on invocation. should unlock functionality in updatedtransactions:
states skpaymenttransactionstatepurchased
, skpaymenttransactionstaterestored
ios in-app-purchase restore
No comments:
Post a Comment