nmalik_1769
nmalik_1769

Reputation: 11

I have a issue with call Directory Handler Extension Swift 3 CallKit

I am getting an error when I am enabling the extension I have added in my project please tell me how to solve this here is the screenshot Error Image

If you need any other details please ask me I will provide them.

 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()
    }

Upvotes: 1

Views: 1896

Answers (2)

CD-3
CD-3

Reputation: 63

I had this same issue and was able to git rid of the error and successfully link the Call Directory Extension when I added the data model for my extension to the target directory build phases.

Select your project > select your target extension > select Build Phases > + to Compile Sources.

Hope this helps!

Upvotes: 1

Alan Kinnaman
Alan Kinnaman

Reputation: 927

I'd suggest checking the error code in the CXCallDirectoryExtensionContextDelegate. Put this code in the requestFailed function:

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.")
    }
}

Now, debug your extension in Xcode. (See details here.) When you attempt to enable your extension in settings, Xcode should print an error message describing what went wrong.

Upvotes: 3

Related Questions