In App Purchase causes occasional crash

后端 未结 1 1999
温柔的废话
温柔的废话 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)
自定义标题
段落格式
字体
字号
代码语言
提交回复
热议问题