We are developing an Ionic
app for Android
and iOS
that has Push Notifications
. We send these notifications via Firebase Cloud Messaging
On iOS
we have this problem (we have accepted Notifications Permission for the app):
- When the app is in
foreground
, we get the notification instantly (we get it inside the app, not with a card). - When the app is closed or in
background
it seems like we do not get the notification. However wehn we open or resume the app, we get the notification as is it was recieved with the app inforeground
. Our hypothesis is that we are gettingsilent notifications
. - (When we send Firebase test notification we get the same behaviour).
We have the next configurations:
- Xcode: Capabilities -> Background Modes -> Remote Notifications (shows one check)
- Xcode: Capabilities -> Push Notifications (shows two checks)
- Apple Developer: Identifiers -> my app -> Push Notifications (with certificates for both dev and prod)
- Apple Developer: Keys -> .p8 key with "Apple Push Notifications service (APNs)"
- Firebase: my app -> Configuration -> Cloud Messaging (.p8 file uploaded with key and team IDs)
This is one of the several notifications we have tried to send via Firebase POST API, which combines almost everything we have read while researching this problem. (we also send required Firebase HTTP headers)
{
"to": "<firebase_token>",
"notification": {
"body": "NOTIFICATION BODY",
"title": "NOTIFICATION TITLE",
},
"apns": {
"headers": {
"apns-push-type": "alert",
"apns-expiration": 0,
"apns-priority": 5,
"apns-topic": "<my_app>"
},
"payload": {
"alert": {
"title": "NOTIFICATION TITLE",
"body": "NOTIFICATION BODY"
},
"aps": {
"content-available": 1,
"alert": {
"title": "NOTIFICATION TITLE",
"body": "NOTIFICATION BODY"
}
},
"sound": "default",
"content-available": 1
}
},
"data": {
"field": "1",
"type": "CHAR"
}
}
Despite this POST
request may be incorrect for bacground notifications, we believe that would not be the problem, as Firebase test notifications also fail to show when on background.