0
votes

Right now I have a framework that receives a silent notification, get the data from it (custom data) and translate it into a local notification to show the alert to the user (this is donde in didReceiveRemoteNotification:fetchCompletionHandler method). I have implemented this framework on an app and everything seems to be working correctly, silent notifications are being process when the app is in background and foreground. However, when the app is killed by the user or it is not running, I cannot receive notifications because of this:

Use this method to process incoming remote notifications for your app. Unlike the application:didReceiveRemoteNotification: method, which is called only when your app is running in the foreground, the system calls this method when your app is running in the foreground or background. In addition, if you enabled the remote notifications background mode, the system launches your app (or wakes it from the suspended state) and puts it in the background state when a remote notification arrives. However, the system does not automatically launch your app if the user has force-quit it. In that situation, the user must relaunch your app or restart the device before the system attempts to launch your app automatically again.

The reason I use this method for showing notifications is because the payload I sent to APNS has custom data with key-values that indicate how the notification must behave.

I've been doing some research and I found that Pushkit for VoIP can do the job. However, many post suggest that this can cause app rejection.

So my question is, how can I achieve receiving remote notifications even if my app was killed and considering that data in the payload has custom information to build the notification?

1
In the past you could use PushKit but now you can only do so to indicate an incoming call for a voip app. If you receive a PushKit notification and do not subsequently indicate an incoming call to iOS your app will be terminated. There is no solution for your problem. If the user terminated the app you will not receive remote notifications until the user re-launches the app. Consider adding a default notification payload to be shown if your app isn't running.Paulw11
I really appretiate it @Paulw11, I just was like looking a confirmation since I been researching a lot. I just have a doubt. When sending default push notification, with apns predefined keys, a notification as an alert can be displayed even if the app is not running, this behavior is because the notification is processed for IOS tray, and what I am doing with silent notification is processed inside the app, that is why the app must be running. am I right about this ?Rafael
Yes, that could be an issue; I am not sure if iOS will suppress the alert part of the message if your app is running. You might need to test thatPaulw11

1 Answers

1
votes

Silent push notifications are unreliable: they might get delayed, delivered in groups or even not delivered at all.

If you need to modify the content of the notification before presenting a banner for the user, you should use a Notification Service App Extension. You can also share some information between your app and this extension - using app groups or the keychain - if it needs something from your app to process the notification data.