Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does the Call Directory Extension in iOS get updated

I have an app that I'm developing and I want to store a few thousand phone numbers using the Call Directory Extension of CallKit.

What I'm confused about is, how and when does the extension get called? It doesn't seem like it happens with every phone call. Does it happen whenever the app is started?

The reason I'm asking, I don't want to keep the thousands of phone numbers in my app. I don't want the user to see these phone numbers (unless of course, they get a call from one of them). So, what I want to do is save the phone numbers using the Extension one time, with numbers loaded from a web service, but only periodically.

Thank you!

like image 267
Danny Ackerman Avatar asked Jul 22 '18 01:07

Danny Ackerman


1 Answers

The extension will be loaded whenever the user turns it on from the caller ID settings. You can also manually reload it using the reloadExtension method of CXCallDirectoryManager.

You need to share data between your main app and the extension using an App Group.

Your main app is responsible for fetching the data periodically (using whatever method you like; manual trigger by the user or background fetch for example) and updating the shared database. It then calls CXCallDirectoryManager.sharedInstance.reloadExtension(withIdentifier:completionHandler:) to reload the extension. identifier is the string bundle id of your CallKit extension.

The extension simply needs to retrieve all of the data from the shared database and register it with the CXCallDirectoryExtensionContext

like image 153
Paulw11 Avatar answered Oct 22 '22 16:10

Paulw11