【问题标题】:I have a issue with call Directory Handler Extension Swift 3 CallKit我对呼叫目录处理程序扩展 Swift 3 CallKit 有疑问
【发布时间】:2017-10-15 14:39:48
【问题描述】:

启用我在项目中添加的扩展时出现错误,请告诉我如何解决此问题,这是屏幕截图Error Image

如果您需要任何其他详细信息,请询问我,我会提供。

 private func addAllBlockingPhoneNumbers(to context: CXCallDirectoryExtensionContext) {

    for i in 0...numbers.count - 1
    {


    let allPhoneNumbers: [CXCallDirectoryPhoneNumber] = [ numbers[i] ]
    for phoneNumber in allPhoneNumbers {
        context.addBlockingEntry(withNextSequentialPhoneNumber: phoneNumber)
    }
    }
}

----------------------------

   override func beginRequest(with context: CXCallDirectoryExtensionContext) {
        context.delegate = self


        numbers = DBManager.shared.selectContacts()
    }

【问题讨论】:

  • 最好看你的源代码
  • 我添加了一些代码,请检查它@GabrielLidenor

标签: ios swift uitableview callkit


【解决方案1】:

我建议检查CXCallDirectoryExtensionContextDelegate 中的错误代码。将此代码放入requestFailed函数中:

func requestFailed(for extensionContext: CXCallDirectoryExtensionContext, withError error: Error) {        
    let errorCode = (error as NSError).code
    switch errorCode {
    case CXErrorCodeCallDirectoryManagerError.Code.unknown.rawValue:
        print("Extension could not be load for an unknown reason.")
    case CXErrorCodeCallDirectoryManagerError.Code.noExtensionFound.rawValue:
        print("Could not load extension.  Extension not found")
    case CXErrorCodeCallDirectoryManagerError.Code.loadingInterrupted.rawValue:
        print("Could not load extension.  Extension was interrupted while loading")
    case CXErrorCodeCallDirectoryManagerError.Code.entriesOutOfOrder.rawValue:
        print("Could not load extension.  Call entries are out of order")
    case CXErrorCodeCallDirectoryManagerError.Code.duplicateEntries.rawValue:
        print("Could not load extension.  Duplicate entries")
    case CXErrorCodeCallDirectoryManagerError.Code.maximumEntriesExceeded.rawValue:
        print("Could not load extension.  Maximum entries exceeded")
    case CXErrorCodeCallDirectoryManagerError.Code.extensionDisabled.rawValue:
        print("Extension not enabled in Settings")
    case CXErrorCodeCallDirectoryManagerError.Code.unexpectedIncrementalRemoval.rawValue:
        print("Unexpected incremental removal")
    case CXErrorCodeCallDirectoryManagerError.Code.currentlyLoading.rawValue:
        print("Could not load extension.  The extension is currently loading")
    default:
        print("Could not load extension.")
    }
}

现在,在 Xcode 中调试您的扩展。 (See details here.) 当您尝试在设置中启用您的扩展时,Xcode 应该会打印一条错误消息来描述发生了什么问题。

【讨论】:

    【解决方案2】:

    当我将扩展的数据模型添加到目标目录构建阶段时,我遇到了同样的问题并且能够摆脱错误并成功链接调用目录扩展。

    选择您的项目 > 选择您的目标扩展 > 选择 Build Phases > + 以编译源代码。

    希望这会有所帮助!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-04-18
      • 2016-11-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多