ios callkitmanger usage in swift

  1. Add below line in the head

    import CallKit
    let extensionIdentifier:String = "Your extension identifier"
    
  2. To check the enable status of extension

    func checkEnableStatus() {
       let globalQueue = DispatchQueue.global()
       globalQueue.async {
           self.callmanager.getEnabledStatusForExtension(withIdentifier: extensionIdentifier, completionHandler: {(enablestatus: CXCallDirectoryManager.EnabledStatus, error:Error?) in
               if error == nil {
                   switch enablestatus {
                   case .disabled:
                       self.enableStatus = false
                   case .enabled:
                       self.enableStatus = true
                   case .unknown:
                       self.enableStatus = false
                   }
                   self.delegate?.didUpdateEnableStatus(status: self.enableStatus)
               }
           })
       }
    }
    
  3. To reload phone data of extension

    func reloadData() {
       let globalQueue = DispatchQueue.global()
       globalQueue.async {
           self.callmanager.reloadExtension(withIdentifier: extensionIdentifier, completionHandler: {(error:Error?) in
               var status:Bool = false
               if error == nil {
                   status = true
                   print ("load phone number data successful.")
               } else {
                   print ("error when reload phone data.")
    //                    print (error?.localizedDescription)
               }
               self.delegate?.didReloadPhoneData(status: status)
           })
    
       }
    }
    

转载请注明来源,欢迎对文章中的引用来源进行考证,欢迎指出任何有错误或不够清晰的表达。可以在下面评论区评论,也可以邮件至[email protected]