gpt4 book ai didi

ios - Swift 应用内购买失败,但系统对话框显示您已准备就绪

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

我有一个具有应用内购买功能的应用。问题是即使我收到错误,例如由于“无法连接到 iTunes Store”而导致的失败案例,系统对话框也会显示“您已准备就绪。购买成功”。你可以找到我的 inApp 购买助手类代码。

  public func paymentQueue(_ queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction]) {
for transaction in transactions {
switch (transaction.transactionState) {
case .purchased:
NotificationCenter.default.post(name: .IAPHelperSetPepqueenNotification, object: nil)

if let url = Bundle.main.appStoreReceiptURL {
guard let receipt = try? Data(contentsOf: url) else {
print("error to take receipt")
return
}
let receiptData: String = receipt.base64EncodedString(options: .init(rawValue: 0))
PepappNetwork.request(target: .postReceipt(platform: "ios", receipt: receiptData) , success: { (JSON) in
print(JSON)
let user = User(JSON: JSON["data"].dictionaryObject!)
UserDefaults.standard.set(user?.identifier, forKey: "userID")
user?.persist()

if user?.language != nil {
UserDefaults.standard.set(user!.language!, forKey: "forcedLanguage")
UserDefaults(suiteName: Constants.UserDefaults.containerName)!.set(user!.language!, forKey: "forcedLanguage")
}

NotificationCenter.default.post(name: Notification.Name.CurrentUserChanged, object: nil)
self.complete(transaction: transaction)

}, error: { (errorString, _) in

}) { (MoyaError) in

}
}
break
case .failed:
NotificationCenter.default.post(name: .IAPHelperCancelNotification, object: nil)
fail(transaction: transaction)
break
case .restored:
restore(transaction: transaction)
break
case .deferred:
break
case .purchasing:
break
}
}
}

交易失败函数

private func fail(transaction: SKPaymentTransaction) {
print("fail...")
if let transactionError = transaction.error as NSError?,
let localizedDescription = transaction.error?.localizedDescription,
transactionError.code != SKError.paymentCancelled.rawValue {
print("Transaction Error: \(localizedDescription)")

}

在应用进入更新交易功能之前,“您已准备就绪。”对话框已经显示。

最佳答案

Apple Sandbox 存在问题,现已解决 - https://developer.apple.com/system-status/

关于ios - Swift 应用内购买失败,但系统对话框显示您已准备就绪,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55158357/

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