自最近两个月以来,我一直面临这个问题
我的App可以自动更新InApp购买,但无法正常运行,然后许多用户抱怨说,当他们单击“购买”按钮时,什么都没发生,所以我调试代码并在我的真实设备上运行,发现此错误
SKPrdouctName失败 错误域= SKErrorDomain代码= 2“无法连接到iTunes Store” UserInfo = {NSLocalizedDescription =无法连接到iTunes Store}
我没有更改任何代码
我没有上传新版本
我的产品也在Appstore Connect上获得批准
我没有对产品进行任何更改
我已经尝试过重启设备,清除缓存,登录注销Apple ID仍然遇到相同的错误
许多实时用户都在发生这种情况
我真的需要一个解决方案
func productsRequest(_ request: SKProductsRequest, didReceive response: SKProductsResponse) {
print(response.products)
products = response.products
for product in response.products {
print(product.localizedTitle)
}
}
func request(_ request: SKRequest, didFailWithError error: Error) {
print(error.localizedDescription)
}
func requestDidFinish(_ request: SKRequest) {
print(request)
Global.sharedInstance.isConsiderPurchasedOrNot = true
}
}
func paymentQueue(_ queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction]) {
for transaction in transactions {
print(transaction.transactionState.status(), transaction.payment.productIdentifier)
switch transaction.transactionState {
case .purchasing:
break
case .purchased:
Miscellaneous.APPDELEGATE.window!.stopMyToastActivity()
if Global.sharedInstance.isConsiderPurchasedOrNot{
print(transaction.payment.productIdentifier + "is purchased")
let prodID = transaction.payment.productIdentifier as String
if prodID == MyProducts.autoRenewSubscription
{
Global.sharedInstance.isPurchased = 1
purchaseSubscriber(usediD: Global.getUserID())
}
}
break
case .restored:
print(transaction.payment.productIdentifier + "is purchased/restored! hello ")
// let str1 = UserDefaults.standard.string(forKey: "username")
Global.sharedInstance.isPurchased = 1
let prodID = transaction.payment.productIdentifier as String
Miscellaneous.APPDELEGATE.window!.stopMyToastActivity()
if prodID == MyProducts.autoRenewSubscription
{
Global.sharedInstance.isPurchased = 1
}
case .failed:
print(transaction.payment.productIdentifier + "is failed!")
Miscellaneous.APPDELEGATE.window!.stopMyToastActivity()
default: queue.finishTransaction(transaction)
}
}
}