How does the Call Directory Extension in iOS get updated
Asked Answered
R

1

6

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!

Romonaromonda answered 22/7, 2018 at 1:49 Comment(0)
S
8

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

Shockheaded answered 22/7, 2018 at 1:56 Comment(4)
Thanks! So theoretically, I can download the data, populate it using the CXCallDirectoryManager, erase the data from my local data store, and all the names and phone numbers will be "out of reach" to anyone who may try to fetch them from the inner workings of iOS? It sounds a little crazy, but I'm going to download 1,500 phone numbers that I don't want people to have in their entirety, but if someone from the list calls them, I want them t know who it is.Romonaromonda
You should be able to do that, however a determined attacker will probably just intercept the network traffic. You will need your main app to check the enabled status of the call extension and delete the data/not download it if it is disabledShockheaded
One more following question: does reloadExtension reset the previous data?Nealon
It is up to what you implement in your extension. You need to explicitly remove the entries if you want to developer.apple.com/documentation/callkit/…Shockheaded

© 2022 - 2024 — McMap. All rights reserved.