Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error in CallKit CallDirectory Extension

Tags:

swift

callkit

im implementing callKit in my iOS project, im using the callDirectory extension to block and identify Numbers, the block part works perfectly , the only problem is when i try to add numbers to be identified:

private func retrievePhoneNumbersToIdentifyAndLabels() -> (phoneNumbers: [String], labels: [String])? {
    // retrieve list of phone numbers to identify, and their labels
    interDefaults?.synchronize()
    if let numbers = interDefaults!.string(forKey: "ident-numbers"){
        if let identities = interDefaults!.string(forKey: "ident-identities"){
            let formattedNumbers = numbers.characters.split{$0 == "*"}.map(String.init)
            let formattedIdent = identities.characters.split{$0 == "*"}.map(String.init)
            return (formattedNumbers, formattedIdent)
        }
    }
    return ([""], [""])

}

When i try to relaod the extension it fails with error : Error Domain=com.apple.CallKit.error.calldirectorymanager Code=3 "(null)"

with some testing i figured out that by replacing the formattedIdent with an array of 1 element EXP: ["Spamm Caller"] the extension works perfectly and shows no error but when i use an array with more than one element the same error shows up. im i doing something wrong ?? thanks in advance

like image 474
Med Abida Avatar asked Nov 07 '16 07:11

Med Abida


2 Answers

I had similar issue but the mistake I did was with error code 4. So I digged in the CXErrors and found this enum.

public enum Code : Int {


        public typealias _ErrorType = CXErrorCodeCallDirectoryManagerError

        case unknown

        case noExtensionFound

        case loadingInterrupted

        case entriesOutOfOrder

        case duplicateEntries

        case maximumEntriesExceeded

        case extensionDisabled

        @available(iOS 10.3, *)
        case currentlyLoading

        @available(iOS 11.0, *)
        case unexpectedIncrementalRemoval
    }

So basically unknown == Code 0 and the other options increment with one. This is the full list of errors you can receive while your extension tries to handle new data up to this date.

like image 161
dvp.petrov Avatar answered Oct 20 '22 04:10

dvp.petrov


The error codes from CallDirectory are defined in the header <CallKit/CXError.h>, which includes:

    CXErrorCodeCallDirectoryManagerErrorEntriesOutOfOrder = 3,

This particular error is returned when the phone number(s) provided are out of order. Numbers must be provided in numerically ascending order.

like image 2
Stuart M Avatar answered Oct 20 '22 05:10

Stuart M