CallKit extension for Xojo iOS application
You can add a CallKit extension to your Xojo iOS application. This extension can provide names for phone numbers to iOS as well as block specific numbers. The extension is a background application, which is called from time to time to be asked for new data. Your main application may manage a database of phone numbers, which is then used by the extension.
Since we can't write the CallKit in Xojo right away, we need to write the extension in Xcode. In Xcode you make a new iOS App project. The name doesn't matter, but it may be good to match it to your main application in Xojo and use the same bundle identifier, so Xcode can setup provision profile for you. Then we you have the settings open for the project, on the bottom below the targets is a plus button. There you can add a new target for the Call Directory Extension.
For the call extension project, please choose a good name similar to your app. You can choose whether you prefer Objective-C or Swift as programming language. You may want to use whichever is easier for you.
With adding the target, you get new .m or .swift files into the project to implement the CallDirectoryHandler class (subclass of CXCallDirectoryProvider). Here you can change code to provide the right phone numbers with calling methods addBlockingEntryWithNextSequentialPhoneNumber/removeBlockingEntryWithPhoneNumber methods for phone number blocking entries and addIdentificationEntryWithNextSequentialPhoneNumber/removeIdentificationEntryWithPhoneNumber methods for identification entries. The phone number is passed as Int64 with country prefix, e.g. 555-1234-567 in the US would be 15551234567. Here you may add code to load data from shared sqlite database, a text file or an entry in the user defaults (preferences).
You now build the project for either simulator or any device to get both variants of your extensions. You may need to lookup where your Xcode stored the derived data and then look into the test-floihgzdxpwmipavccgmfmkhdiao/Build/Products/Debug-iphonesimulator/MyAppCallExtension.appex path (or similar) to find the extension you just built. Look in the app there to find the location and info.plist entries. So the appex bundle goes into a folder named "PlugIns" with a capital i.
You may want to read about application groups in Apple's documentation. If the application and the extension are in the same app group, they can access a shared folder with e.g. a shared file for the phone numbers. You may use something like this code to get the shared folder for the group:
Dim fileManager As New NSFileManagerMBS
Dim folder As FolderItem = fileManager.containerFolderForSecurityApplicationGroupIdentifier(AppGroup)
Once you have the application extension ready, you can include in your application some code with our CXCallDirectoryManagerMBS class to provide GUI to reload the extension or open settings. In debugging, you will have to regularly reload the extensions and then log the calls to system console, so you can see them on your Mac and see when what is called.
In trouble shooting, make sure both app and extension are signed with the same identity. Also make sure you don't mix simulator and device versions. The bundle identifier for the app and the extension need to be different. But both should have the same app group setting for the entitlements. If you add the entitlement to the app in Xcode, you may easily find the entitlements file to use for Xojo, too.