Get a list of purchased products, inApp Buy iPhone

I am implementing applications for my iOS application. Apple abandoned my binary code for not recovering purchased products. In my application, when a user removes the product icon, if the item is blocked, he is sent to the inApp purchase process, otherwise the products become open. There is no Buy button. Now an apple says to provide a restore button? Can someone tell me how to handle this? I tried

- (void) checkPurchasedItems { [[SKPaymentQueue defaultQueue] restoreCompletedTransactions]; }// Call This Function //Then this delegate Function Will be fired - (void) paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue *)queue { alreadyPurchasedItems = [[NSMutableArray alloc] init]; NSLog(@"received restored transactions: %i", queue.transactions.count); for (SKPaymentTransaction *transaction in queue.transactions) { NSString *ID = transaction.payment.productIdentifier; [alreadyPurchasedItems addObject:ID]; } } 

When the application starts, but the paymentQueueRestoreCompletedTransactionsFinished method is never called, so I can get a list of already purchased items, and then directly inform the user if he / she has already purchased this.

0
source share
1 answer

How to set the delegate from [SKPaymentQueue defaultQueue] ? I think you are already doing smt like:

 [[SKPaymentQueue defaultQueue] addTransactionObserver:self]; 

After that [[SKPaymentQueue defaultQueue] restoreCompletedTransactions]; should cause the method to run below. So, the SKPaymentTransactionStateRestored script is the one where you implement it:

 -(void) paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions { for (SKPaymentTransaction * transaction in transactions) { switch (transaction.transactionState) { case SKPaymentTransactionStatePurchased: ... [[SKPaymentQueue defaultQueue] finishTransaction:transaction]; break; case SKPaymentTransactionStateFailed: ... [[SKPaymentQueue defaultQueue] finishTransaction:transaction]; break; case SKPaymentTransactionStateRestored: ... [[SKPaymentQueue defaultQueue] finishTransaction:transaction]; default: break; } }; } 

You can take a look at this tutorial, the recovery is explained in more detail to the very end. http://www.raywenderlich.com/21081/introduction-to-in-app-purchases-in-ios-6-tutorial

+3
source

All Articles