Я строю проект для покупки в приложении. Ниже приведены части исходного кода:
- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions
{
NSLog(@"paymentQueue update");
for (SKPaymentTransaction *transaction in transactions)
{
switch (transaction.transactionState)
{
case SKPaymentTransactionStatePurchased:
[self completeTransaction:transaction];
break;
case SKPaymentTransactionStateFailed:
[self failedTransaction:transaction];
break;
case SKPaymentTransactionStateRestored:
[self restoreTransaction:transaction];
default:
break;
}
}
}
- (void) completeTransaction: (SKPaymentTransaction *)transaction
{
NSLog(@"completeTransaction");
// Your application should implement these two methods.
[self recordTransaction: transaction];
[self provideContent: transaction.payment.productIdentifier];
// Remove the transaction from the payment queue.
[[SKPaymentQueue defaultQueue] finishTransaction: transaction];
}
- (void) restoreTransaction: (SKPaymentTransaction *)transaction
{
NSLog(@"restoreTransaction");
[self recordTransaction: transaction];
[self provideContent: transaction.originalTransaction.payment.productIdentifier];
[[SKPaymentQueue defaultQueue] finishTransaction: transaction];
}
- (void) failedTransaction: (SKPaymentTransaction *)transaction
{
NSLog(@"failedTransaction");
if (transaction.error.code != SKErrorPaymentCancelled)
{
// Optionally, display an error here.
}
[[SKPaymentQueue defaultQueue] finishTransaction: transaction];
}
//Optional, record the transaction infomation
- (void) recordTransaction: (SKPaymentTransaction *)transaction{
receipt=transaction.transactionReceipt;
[[NSUserDefaults standardUserDefaults] setValue:transaction.transactionReceipt forKey:@"proUpgradeTransactionReceipt" ];
[[NSUserDefaults standardUserDefaults] synchronize];
[self sendReceipt:receipt];
expiredTime=transaction.transactionDate;
}
Я могу добавить оплату и успешно совершить покупку в песочнице,
но завершенные транзакции не удаляются из defaultQueue после выполнения finishTransaction:
.
DefaultQueue накапливается, когда я добавляю платеж.
Я ошибаюсь?
Спасибо за любую помощь.