gpt4 book ai didi

iOS "This in-app purchase has already been bought"弹窗

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

我的 iOS 应用程序出现问题:当我触摸“购买”按钮购买 IAP 产品时,弹出窗口显示此消息:

This In-App purchase has already been bought. It will be restored for free.

我以前从来没有过这个弹窗,而且我的产品只是非续订,所以我想知道为什么在购买订阅时会出现这个信息。

当我触摸确定关闭此弹出窗口时,购买并未执行。

这是我的代码:

for transaction in transactions {
switch transaction.transactionState {

case SKPaymentTransactionState.Purchased, SKPaymentTransactionState.Restored:
print("Transaction completed successfully.")
SKPaymentQueue.defaultQueue().finishTransaction(transaction)
transactionInProgress = false
// Sauvegarde le produit acheté
savePurchasedProduct(transaction.transactionDate!);
break

case SKPaymentTransactionState.Failed:
print("Transaction Failed");
SKPaymentQueue.defaultQueue().finishTransaction(transaction)
transactionInProgress = false
break

default:
break
}
}

最佳答案

我遇到了同样的问题。已在此处修复:
My IAP isn't working. Bugs at func Paymentqueue

这是我找到的解决方案:

删除

SKPaymentQueue.defaultQueue().addTransactionObserver(self) 

任何地方都有它,并将它放在每次应用程序启动时都会执行的地方一次(仅一次)(我把它放在 viewDidLoad() 中)。

这将检查所有未完成的交易并在应用加载后终止它们,从而在您的用户触发 IAP 之前消除任何可能的错误。

P.S.:此外,这不是我的问题,但请确保为每个 PurchaseState 执行 finishTransaction(),如下所示:

func paymentQueue(queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction]) {
print("Add Payment")

for transaction:AnyObject in transactions{
let trans = transaction as! SKPaymentTransaction
print(trans.error)
switch trans.transactionState{
case .Purchased:
print("IAP unlocked")
print(p.productIdentifier)

let prodID = p.productIdentifier as String
switch prodID{
case "IAP id":
print("Keep on")
keepOn()
default:
print("IAP not setup")
}
queue.finishTransaction(trans)
break
case .Failed:
print ("Buy error")
queue.finishTransaction(trans)
break
default:
print("default: Error")
break
}
}
}

永远不要忘记这一点:

queue.finishTransaction(trans)  

关于iOS "This in-app purchase has already been bought"弹窗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34001868/

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