gpt4 book ai didi

ios - 清除 SKPAymentQueue : Forcing Unfinished Transactions To Finish

转载 作者:行者123 更新时间:2023-11-28 11:09:23 24 4
gpt4 key购买 nike

我的付款队列中仍然有一些恢复交易 - 因为当我测试有缺陷的恢复购买操作时,一旦交易恢复,我从未调用 finishTransaction

根据一些在线研究,我意识到我必须手动强制完成付款队列中未完成的交易。

有人在 Objective-C 中发布了这段代码:

// take current payment queue
SKPaymentQueue* currentQueue = [SKPaymentQueue defaultQueue];
// finish ALL transactions in queue
[currentQueue.transactions enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
[currentQueue finishTransaction:(SKPaymentTransaction *)obj];
}];

我不知道如何将它转换为 Swift 2.0。

谁能帮我做这个?谢谢:-)

最佳答案

这是一个 for 循环,它将遍历每个待处理的交易并检查状态,并完成购买失败或成功的交易。

let currentQueue : SKPaymentQueue = SKPaymentQueue.default();
for transaction in currentQueue.transactions {
if (transaction.transactionState == SKPaymentTransactionState.failed) {
//possibly handle the error
currentQueue.finishTransaction(transaction);
} else if (transaction.transactionState == SKPaymentTransactionState.purchased) {
//deliver the content to the user
currentQueue.finishTransaction(transaction);
} else {
//handle other transaction states
}
}

关于ios - 清除 SKPAymentQueue : Forcing Unfinished Transactions To Finish,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36090901/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com