Heisenbug
Heisenbug

Reputation: 970

CallKit extension begin request

I'm developing an app with database of blocked numbers. In my beginRequest method I'm doing asynchronous connection to my online database and calling context.completeRequest() in completion block. When is this method called? Apple documentation is not clear for me - Can It be called multiple times? The main reason is to keep list of the blocked numbers in device up to date with my database.

So the questions:

  1. Are asynchronous requests available in CallKit Directory handler?

  2. Is beginRequest method called more than once?

  3. How can I create extension like popup outside my application that would make reporting spam possible without entering my application? like here on the third screenshot.

Upvotes: 2

Views: 1396

Answers (1)

Paulw11
Paulw11

Reputation: 114856

From the Apple Documentation:

Because this method is called only when the system launches the app extension and not for each individual call, you must specify call identification information all at once; you cannot, for example, make a request to a web service to find information about an incoming call.

You can use an asynchronous method in beginRequest to retrieve your data. Once the asynchronous fetch is complete you can then call addBlockingEntry with each number before finally calling completeRequest.

I suspect that the screen you referred to in the linked app is a share extension that was invoked from the "Share Contact" button of the contact.

When you have updated blocking data you can refresh your blocking data by calling CXCallDirectory.sharedInstance.reloadExtension from your main app; you could do this in response to a silent push, when requested by the user or use background fetch.

Upvotes: 5

Related Questions