有时下载会失败,我的应用会在失败时完成交易,正如在任何地方所推荐的那样。但是,如果我完成交易,那么 Store Kit 将无法恢复失败的下载。而且似乎Store Kit在下载失败后不会自动重试下载内容,而且似乎也没有办法触发下载。
有人知道在这种情况下该怎么做吗?违背所有建议,直到内容完全下载和安装后才完成交易?
或者我必须以编程方式恢复交易并忽略所有其他产品标识符吗?
您可以通过这种方式在您的应用中添加恢复购买按钮:-
//inside of an IBaction
[[SKPaymentQueue defaultQueue] addTransactionObserver:self];
[[SKPaymentQueue defaultQueue]restoreCompletedTransactions];
// Then this is called
- (void)paymentQueueRestoreCompletedTransactionsFinishedSKPaymentQueue *)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];
希望对您有所帮助...!!
关于iphone - 如果 Apple 托管的应用内购买内容下载失败怎么办?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16788089/
欢迎光临 OStack程序员社区-中国程序员成长平台 (https://ostack.cn/) | Powered by Discuz! X3.4 |