Swift IOS 13,IAP - "无法连接到Itunes Connect"。

问题描述 投票:0回答:0

我正在使用IOS 13.5,在实施IAP时遇到了一些问题。当我建立以前的应用程序时,我使用了同样的代码,当我在相同的物理设备上测试运行以前的应用程序时,支付工作正常,就像现在这样。

我检查了网络连接,没有问题,证书看起来很好,Itunes Connect中的IAP是 "Ready to submit",应用程序的IAP是启用的,我做了几个沙盒测试,结果都一样。我清理构建并重启了电脑和设备,但它总是说Code=2 "无法连接到Itunes连接"

我甚至尝试上传一个构建到Itunes connect,看看是否会有所改变,没有。我显然遗漏了一些东西,希望能得到关于这个问题的帮助。

呼叫购买启动。

IAPService.shared.purchase(product: .fullAccess)

IAPService。

class IAPService: NSObject {

private override init() {}
static let shared = IAPService()

var products = [SKProduct]()
let paymentQueue = SKPaymentQueue.default()

func getProducts() {
    let products: Set = [IAPProduct.fullAccess.rawValue]
    let request = SKProductsRequest(productIdentifiers: products)
    request.delegate = self
    request.start()
    paymentQueue.add(self)
}

func purchase(product: IAPProduct){
    guard let productToPurchase = products.filter({ $0.productIdentifier == product.rawValue}).first else { return }
    let payment = SKPayment(product: productToPurchase)
    paymentQueue.add(payment)
}

func restorePurchases(){
    print("restoring purchases")
    GlobalVariables.hasFullAccess = false
    GlobalVariables.partialAccessArrayKeys.removeAll()
    paymentQueue.restoreCompletedTransactions()
    CheckPurchase.shared.checkUserPurchase()
}}

extension IAPService: SKProductsRequestDelegate {
    func productsRequest(_ request: SKProductsRequest, didReceive response: SKProductsResponse) {
        self.products = response.products
        for product in response.products {
            print(product.localizedTitle)
        }
    }
}

extension IAPService: SKPaymentTransactionObserver {
    func paymentQueue(_ queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction]) {
        for transaction in transactions {
            print(transaction.transactionState)
            print(transaction.transactionState.status(), transaction.payment.productIdentifier)
            print(transaction.debugDescription)
            if transaction.error != nil {
                print(transaction.error)
            }

        }
    }
}

extension SKPaymentTransactionState {
    func status() -> String {
        switch self {
        case .deferred: return "deferred"
        case .failed: return "failed"
        case .purchased: return "purchased"
        case .purchasing: return "purchasing"
        case .restored: return "restored"
        }
    }
}

IAPProduct。

enum IAPProduct : String {
    case fullAccess = "se.marcusthuvesen.Torst.FullAccess"
}
ios swift xcode in-app-purchase storekit
© www.soinside.com 2019 - 2024. All rights reserved.