gpt4 book ai didi

ios - 关于在应用商店处理 iAP 成功的问题

转载 作者:行者123 更新时间:2023-11-29 05:55:38 25 4
gpt4 key购买 nike

如果用户之前没有付款信息,当 iAP 流程启动时,应用程序会将用户重定向到应用程序商店,以获取用户填写的付款信息,当用户已经完成付款信息时,付款完成(获取提醒购买)成功)资金被切断,应用程序商店没有将用户重定向回应用程序,如果用户返回到应用程序,则会发生通知。

SKPaymentTransactionObserver 没有调用,用户没有获得任何消耗品(应用程序中的信用)

func paymentQueue(_ queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction]) {
for transaction in transactions {
switch transaction.transactionState {
case .deferred:
print("transactionState = deferred")
case .purchasing:
print("transactionState = purchasing")
case .purchased:
print("transactionState = purchased")
SKPaymentQueue.default().finishTransaction(transaction)
SKPaymentQueue.default().remove(self)
var receiptBase: String = ""
if let receiptURL = Bundle.main.appStoreReceiptURL {
do {
let receipt = try Data(contentsOf: receiptURL)
let base64encodedReceipt = receipt.base64EncodedString()
receiptBase = base64encodedReceipt
} catch {
receiptBase = ""
}
}
//call api for add consumable to user
buyCreditDelegate?.purchasedCredit(transactionId: transaction.transactionIdentifier ?? "", receiptId: receiptBase)
case .failed:
SKPaymentQueue.default().finishTransaction(transaction)
SKPaymentQueue.default().remove(self)
if let delegate = self.buyCreditDelegate {
delegate.cancelPurchases()
}
case .restored:
print("transactionState = restored")
}

仅供引用:我的 iAP 是消耗品。

我该如何解决这个问题,抱歉我的英语不好

最佳答案

删除此行:

SKPaymentQueue.default().remove(self)

您需要您的观察者成为像应用程序委托(delegate)一样永久的持久对象。切勿将其移除,否则商店无法与您交谈。

关于ios - 关于在应用商店处理 iAP 成功的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55197237/

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