APNS notifications are not received when app is in background

We are using APNS and FCM services to notify other users on our app for the messages posted by the users at One-One and Group Chat on our application. We are sending the notifications through Python API using FCM and APNS libraries.

In few cases when app is in background notifications are not received by the device but we see the response as success along with message id being returned please find the attached details for reference.

APNS notification payload:

{'title': 'Bhonagiri', 'body': 'Ttyyedf', 'jid': 'jid@domain', 'content-available': 1, 'xml': "1XXXxxx url<CONVERSATION_TYPE xmlns='urn:xmpp:conversationType'>1</CONVERSATION_TYPE>1628750128263Ttyyedf", 'sound': 'default'}

APNS notification response for the above message:

{'multicast_ids': [3702581774227590477], 'success': 1, 'failure': 0, 'canonical_ids': 0, 'results': [{'message_id': '1628750130259539'}], 'topic_message_id': None}**

The behavior you are seeing is expected, and it is due to content-available (aka "background" or "silent") push notifications being throttled when being delivered to apps that are in the background. Background push notifications are never guaranteed to be delivered to the app every single time.

If you need to execute code in response to a notification, 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 long 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.

APNS notifications are not received when app is in background
 
 
Q