有时下载失败,我的应用程序在失败时完成交易,无处不在。但如果我完成交易,则Store Kit无法恢复失败的下载。并且似乎Store Kit在下载失败后不会自动重试下载内容,并且似乎也无法触发下载。
有人在这种情况下想出了该做什么吗?反对所有建议,直到内容完全下载并安装完成后才完成交易?
或者我必须以编程方式还原事务并忽略所有其他产品标识符吗?
答案 0 :(得分:1)
您可以在应用中添加恢复购买按钮: -
//inside of an IBaction
[[SKPaymentQueue defaultQueue] addTransactionObserver:self];
[[SKPaymentQueue defaultQueue]restoreCompletedTransactions];
// Then this is called
- (void)paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue *)queue {
NSLog(@"%@",queue );
NSLog(@"Restored Transactions are once again in Queue for purchasing %@",[queue transactions]);
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];
NSLog (@"product id is %@" , productID);
// here put an if/then statement to write files based on previously purchased items
// example if ([productID isEqualToString: @"youruniqueproductidentifier]){write files} else { nslog sorry}
}
}
或强>
[[SKPaymentQueue defaultQueue] restoreCompletedTransactions];
希望这能帮助你...... !!