我有一个调用Directory Handler Extension Swift 3 CallKit的问题

时间:2017-10-15 14:39:48

标签: ios swift uitableview callkit

当我启用我在项目中添加的扩展程序时出现错误请告诉我如何解决此问题,屏幕截图为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()
    }

2 个答案:

答案 0 :(得分:1)

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

选择您的项目>选择目标扩展程序>选择Build Phases> +编译来源。

希望这有帮助!

答案 1 :(得分:0)

我建议您检查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应打印一条错误消息,说明出现了什么问题。