IAP Customized Recovery Transactions
I'm new to iOS and I'm wondering if there is an option to specify which completed transaction user wants to recover? I am currently using:
[[SKPaymentQueue defaultQueue] restoreCompletedTransactions];
And I can't find anything there to indicate exactly which transaction I want to recover.
Thank!
+3
source to share
1 answer
You are on the right track. Add to
[[SKPaymentQueue defaultQueue] addTransactionObserver:self];
[[SKPaymentQueue defaultQueue] restoreCompletedTransactions];
And add the paymentQueueRestoreCompletedTransactionsFinished delegate function. In this function, you can bind a specific product ID.
- (void) paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue *)queue
{
NSMutableArray *purchasedItemIDs = [[NSMutableArray alloc] init];
//NSLog(@"received restored transactions: %i", queue.transactions.count);
for (SKPaymentTransaction *transaction in queue.transactions)
{
NSString *productID = transaction.payment.productIdentifier;
[purchasedItemIDs addObject:productID];
if([productID isEqualToString:IN_APP_KEY_UNLOCK_SHIP_2])
{
//NSError *error = nil;
[[NSNotificationCenter defaultCenter] postNotificationName:@"ship2PurchaseRestored" object:nil];
}
}
}
0
source to share