I am developing a framework that process silent notifications in order to deploy a local notification (with an alert), the reason of this is that I am sending data messages from Firebase where the payload has custom key-value pairs (that indicates how the notification must behave), so I have to receive them in the app in order to translate them.
Everything works fine, I am receiving notifications in foreground and background while the app is executing. The problem is that I can not receive notifications when the app is killed by the user or completely closed. The reason of this is indicated in Apple docs that says that didReceiveRemoteNotification:fetchCompletionHandler
will not be executed if the user has closed the app because the system will not launch the app.
So, I was told that I should be using default apns key-value pair to receive a default push notification even when the app is closed and use Notification Service Extension if I want to modify or add something to the notification getting the request´s content.
The problem I have is that I should do some extra process when I receive a silent notification, like reporting that I receive it. And this is the reason I think the app should be executing, because it need execution time.
But I been thinking and researching and I cannot understand how other apps (like youtube, facebook .. etc) can receive notifications with an image attach even if the app is closed, is it not supposed that in order to add an attachment you need to have whatever you are attaching locally ?, so you should have downloaded it somehow, and this process require the app to have time for executing that task, or this is managed by IOS ?
Or am I missing something about push notification ?