I'm working on a message filter extension for iOS and I am kind of stuck. I would like to make an API call inside the extension class that is responsible with filtering the received messages but so far it's not working. I can use exactly the same code inside the ViewController class and everything is working fine.
So my question is: is it possible to make an API call from a message filter extension? (if it is, is there some kind of special setup that I am missing?)
According to the documentation it is not possible to make any network calls inside the extension, the system should handle it and communicate with server associated with your app for you
For privacy reasons, the system handles all communication with your associated server; your Message Filter app extension can't access the network directly.
Also for privacy reasons, your app extension can't write data to containers shared with the containing app.
So to make the call to your server you should call deferQueryRequestToNetwork(completion:)
on the ILMessageFilterExtensionContext
instance
If your app extension can't make this determination by itself, it tells Messages to send the information about the message to a server associated with your app. Your server examines the message information and sends a response to Messages, which passes the response to your app extension.