首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >我对call Directory Handler扩展Swift 3 CallKit有一个问题

我对call Directory Handler扩展Swift 3 CallKit有一个问题
EN

Stack Overflow用户
提问于 2017-10-15 14:39:48
回答 2查看 1.4K关注 0票数 1

当我启用在我的项目中添加的扩展时,我收到了一个错误,请告诉我如何解决这个问题,这里是屏幕截图误差图像

如果你需要任何其他细节,请问我,我会提供他们。

代码语言:javascript
运行
复制
 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)
    }
    }
}

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

代码语言:javascript
运行
复制
   override func beginRequest(with context: CXCallDirectoryExtensionContext) {
        context.delegate = self


        numbers = DBManager.shared.selectContacts()
    }
EN

回答 2

Stack Overflow用户

发布于 2017-10-22 04:19:40

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

代码语言:javascript
运行
复制
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调试扩展。(详见此处.)当您试图在设置中启用扩展时,Xcode应该打印一条错误消息,说明出了什么问题。

票数 3
EN

Stack Overflow用户

发布于 2018-01-26 15:28:31

我也有同样的问题,当我将扩展的数据模型添加到目标目录构建阶段时,我能够排除错误并成功地链接Call Directory扩展。

选择您的项目>选择您的目标扩展>选择构建阶段>+编译源代码。

希望这能有所帮助!

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46756239

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档