In App Purchase causes occasional crash

后端 未结 1 2012
温柔的废话
温柔的废话 2021-01-07 04:39

I\'ve searched the internet for help on this but to no avail. My app is live on the app store and a minority of users are reporting the app freezing on them and crashing aft

相关标签:
1条回答
  • 2021-01-07 05:15

    This is the crash because of the memory issue. I think you putto code like this after some delay it works batter. you can also use GCD Dispatch Timer

    public func paymentQueue(queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction]) {

    let delayTime = dispatch_time(DISPATCH_TIME_NOW, Int64(0.1 * Double(NSEC_PER_SEC)))
                    dispatch_after(delayTime, dispatch_get_main_queue()) {
    
                    for transaction in transactions {
      switch (transaction.transactionState) {
      case .Purchased:
        completeTransaction(transaction)
        break
      case .Failed:
        failedTransaction(transaction)
        break
      case .Restored:
        restoreTransaction(transaction)
        break
      case .Deferred:
        break
      case .Purchasing:
        break
      }
     }
    

    } }

    0 讨论(0)
提交回复
热议问题