Я хочу знать, что нужно ли ставить две отдельные кнопки для обновления и другую для восстановления для восстановления предыдущих транзакций ??
Какие шаги я должен предпринять для себяИзбегайте отклонения шансов транзакции App for Restore.
Я использовал приведенный ниже код для восстановления нерасходуемых In App Purchase.Если какие-либо изменения в приведенном ниже коде, пожалуйста, дайте мне знать.
- (void)buyProduct:(SKProduct *)product {
[[SKPaymentQueue defaultQueue] addTransactionObserver:self];
//[[SKPaymentQueue defaultQueue] addPayment:payment];
[[SKPaymentQueue defaultQueue] restoreCompletedTransactions];
}
- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions
{
for (SKPaymentTransaction * transaction in transactions) {
switch (transaction.transactionState)
{
// Call the appropriate custom method for the transaction state.
case SKPaymentTransactionStatePurchasing:
[self showTransactionAsInProgress:transaction deferred:NO];
break;
case SKPaymentTransactionStateDeferred:
[self showTransactionAsInProgress:transaction deferred:YES];
break;
case SKPaymentTransactionStatePurchased:
[self completeTransaction:transaction];
break;
case SKPaymentTransactionStateFailed:
[self failedTransaction:transaction];
break;
case SKPaymentTransactionStateRestored:
[self restoreTransaction:transaction];
default:
// For debugging
NSLog(@"Unexpected transaction state %@", @(transaction.transactionState));
break;
}
};
}
- (void)paymentQueue:(SKPaymentQueue *)queue restoreCompletedTransactionsFailedWithError:(NSError *)error
{
NSLog(@"Restore Completed Transactions Failed WithError...%@",error);
[self failedMessage:@"Restore Completed Transactions Failed"];
[self stopIndicator];
}
- (void)paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue *)queue
{
NSMutableArray *arrPurchasedItemIDs = [[NSMutableArray alloc] init];
for (SKPaymentTransaction *transaction in queue.transactions)
{
NSString *productID = transaction.payment.productIdentifier;
[arrPurchasedItemIDs addObject:productID];
NSLog(@"arrPurchasedItemIDs : %@",arrPurchasedItemIDs);
}
NSLog(@"Restore Completed");
[self completeMessage:@"Restore Completed"];
[self stopIndicator];
}