Silent Push not received when app is in background / dismissed iOS 14.4

I am using FCM with APNS to send Push notifications to my iOS app. I am getting notifications in all modes (foreground, background and dismissed) when app is deployed from Xcode (Xcode version 12.4, iOS version : 14.4). However, issue is when app is downloaded from the Store, I am able to receive the push in foreground but not when app gets dismissed.

Here’s what I am doing :
  • I have changed the key value for aps environment to production in the entitlements file

  • All the process to configure push notifications such as adding capabilities for push notifications and configuring them in app delegate along with firebase configuration is done

  • Whenever push is received,  I am showing local notifications to the user.


Here's my payload info :

let mesg = {
                registration_ids: iosIds,
                data: {
                    commentId: commentId,
                    userId: userid,
                    comment: comment,
                    projectId: projectId,
                    projectName: projectName,
                    commentType: commentType.toString(),
                    userName: userName,
                    type: '1'
                },
                apns: {
                    headers: {
                        "apns-priority": 5,
                    },
                    payload: {
                        aps: {
                            "content-available": 1,
                            alert: ""
                        }
                    }
                },
                content_available: true,
                priority: 'high',
                "apns-priority": 5,
            }
let option = {
                method: 'POST',
                url: 'https:///fcm/send',
                headers: {
                    'Content-Type': 'application/json',
                    'Authorization': 'key=' + functions.config().auth.key
                },
                body: JSON.stringify(mesg)
            }


Please can anyone assist me regarding the same.
When an app is killed by the user (which is what I presume you mean by dismissed) content-available notifications with no visible content (AKA silent pushes) will not be delivered to the app until the user launches the app again.

The reason you saw this working when testing with Xcode is, while debugging the rules for the delivery of silent pushes are relaxed to help with debugging.

You should also be aware that not all silent pushes may be delivered to your app even if it has not been dismissed. Silent pushes are delivered on the discretion of the OS.

I suggest looking into using a notification service extension as discussed at https://developer.apple.com/documentation/usernotifications/unnotificationserviceextension.
The Notification Service Extension will be executed for every *visible* push notification. So, it could serve your needs, as longs as the user has not disabled the visibility of your notifications through various settings.
The service extension will *not* be executed for push notifications that will not be presented visually.

If the reason for this juggling you are doing between silent pushes and a local notification is to change the content of the notification based on some local logic, you can also do that inside the NSE by changing the content on the fly.



Silent Push not received when app is in background / dismissed iOS 14.4
 
 
Q