gpt4 book ai didi

ios - 如何判断购买了哪个IAP?

转载 作者:搜寻专家 更新时间:2023-10-31 22:35:37 26 4
gpt4 key购买 nike

我正在快速编写一些代码来处理 IAP。您如何确定在 paymentQueue 函数中购买了哪个 IAP?

这是我目前的代码:

func paymentQueue(queue: SKPaymentQueue!, updatedTransactions transactions: [AnyObject]!)    {

println("Received Payment Transaction Response from Apple")

for transaction:AnyObject in transactions {
if let trans:SKPaymentTransaction = transaction as? SKPaymentTransaction{
switch trans.transactionState {
case .Purchased:
println("Product Purchased");
SKPaymentQueue.defaultQueue().finishTransaction(transaction as SKPaymentTransaction)
break;
case .Failed:
println("Purchased Failed");
SKPaymentQueue.defaultQueue().finishTransaction(transaction as SKPaymentTransaction)
break;
case .Restored:
println("Product Restored");
SKPaymentQueue.defaultQueue().finishTransaction(transaction as SKPaymentTransaction)
// case .Restored:
//[self restoreTransaction:transaction];
default:

break;
}
}
}
}

最佳答案

SKPaymentTransaction 实例的 payment 属性的 productIdentifier 值为您提供相关产品。


您可以在 its Class Reference 中阅读有关 SKPaymentTransaction 的更多信息.

关于ios - 如何判断购买了哪个IAP?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29104377/

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