【问题标题】:Why is my app crashing on the App Store but not in development?为什么我的应用程序在 App Store 上崩溃但未在开发中?
【发布时间】:2017-07-10 08:00:43
【问题描述】:

我怀疑这与基于订阅的应用内购买有关。在开发模式和 TestFlight 上一切正常,甚至运行 Ad Hoc。但是当它进入 App Store 时,它​​每次都会崩溃。

我检查了崩溃日志,我得到的唯一信息是它是一个 SIGTRAP。

我认为它在这段代码中:

func checkForSubscription {

    print("Checking subscription status")

    guard let receiptURL = Bundle.main.appStoreReceiptURL else {
        return
    }

    let fileManager = FileManager()
    if fileManager.fileExists(atPath: receiptURL.path) {

        do {

            let receipt = try! Data(contentsOf: receiptURL)

            let requestContents = [
                "receipt-data": receipt.base64EncodedString(options: []),
                "password": "secret generated from iTunes Connect"
            ]

            let requestData = try JSONSerialization.data(withJSONObject: requestContents, options: [])
            let storeURL = URL(string: "https://buy.itunes.apple.com/verifyReceipt") 
            let sandboxURL = URL(string: "https://sandbox.itunes.apple.com/verifyReceipt")

            var request = URLRequest(url: storeURL!)
            request.httpMethod = "POST"
            request.httpBody = requestData

            let task = URLSession.shared.dataTask(with: request) { data, response, error in
                guard let httpResponse = response as? HTTPURLResponse, let receivedData = data else {
                    print("No valid http response.")
                    return
                }
                switch (httpResponse.statusCode) {
                case 200:
                    do {
                        let data = try JSONSerialization.jsonObject(with: receivedData, options: .allowFragments)

                        let json = JSON(data) // SwiftyJSON
                        let receipts = json["receipt"]["in_app"].array!
                        let latestReceipts = json["latest_receipt_info"].array!

                        var allReceipts = receipts + latestReceipts

                        var expiresTime: Double = 0

                        for receipt in allReceipts {
                            let expiration = receipt["expires_date_ms"].doubleValue / 1000
                            if expiration > expiresTime {
                                expiresTime = expiration
                            }
                        }

                        let currentTime = NSDate().timeIntervalSince1970
                        let expired = currentTime > expiresTime

                        if expired {
                            subscribed = false
                        } else {
                            subscribed = true
                        }

                    } catch {
                        print(error)
                    }
                default:
                    print("Error code: \(httpResponse.statusCode)")
                }
            }
            task.resume()

        } catch {
            // May be because there is no history of subscription
            print(error)
        }

    } else {
        print("no receipt")
    }

}

【问题讨论】:

  • 哪条线路崩溃了? ——而且,你知道,不是吗,任何时候你放一个感叹号,这意味着“让我崩溃”?我至少看到其中四个。这当然不能被描述为“做正确的事”。
  • 请提供完整的符号化崩溃报告
  • 但是你需要符号化崩溃日志。
  • 所以你成功地欺骗了 Apple 人,让他们接受了一个你知道会崩溃的应用程序,而现在你却抱怨应用程序崩溃了?!
  • 我是在评论,而不是在回答。我无法回答,因为您还没有提供符号化的崩溃日志。如果你想要帮助,那是你必须提供的。你所提供的只是一个虚假的“我得到的唯一信息是它是一个 SIGTRAP”(你有 很多 更多信息,即崩溃日志)和一些我们没有理由的代码think 与崩溃有任何关系(但正如我已经指出的那样,它是容易崩溃的代码)。所以是的,我正在使用 cmets 来批评这个问题——这就是 cmets 的用途。

标签: ios swift in-app-purchase subscription auto-renewing


【解决方案1】:

您可以通过symbolicating your crash report找到崩溃的行。

当您这样做时,您将能够找出导致崩溃的原因并从那里解决问题。

【讨论】:

    【解决方案2】:

    您可以将 Crashlytics 集成到您的应用中,下次如果应用在应用商店崩溃,您将在您的应用崩溃的电子邮件中获得类名和行号。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-09-12
      相关资源
      最近更新 更多