简体   繁体   中英

CTCellularPlanProvisioning().supportsCellularPlan() takes too long

Calling CTCellularPlanProvisioning().supportsCellularPlan() which returns boolean if the device supports esim takes up to 10 seconds to complete which freezes the app. This method seems to be trivial to execute which leads to question why is it taking so long? And how to avoid the app freeze?

To avoid the problem execute the method on a different thread:

func checkEsim(_ completion: @escaping (Bool) -> Void) {
  DispatchQueue.global().async {
    let value = CTCellularPlanProvisioning().supportsCellularPlan()
    DispatchQueue.main.async {
      completion(value)
    }
  }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM