When app is in background doReceiveRemoteNotification is not called from Firebase
With Firebase, I am sending this JSON:
{
"data": {
},
"priority": "high",
"to": "xxxxx",
"content-available": "true",
"notification": {
"body": "HI!",
"title": "FCM Message",
"badge": 1,
"sound": "Default"
}
}
But didReceiveRemoteNotification:fetchCompletionHandler
not called when the app is in the background.
I allow background mode - remote notifications from capabilities.
Any suggestions?
source to share
Your key / value is invalid for content. The key is content_available
(underscore, not dash) and the value is boolean, not string:
{
"data": {
},
"priority": "high",
"to": "xxxxx",
"content_available": true, // <= CHANGED
"notification": {
"body": "HI!",
"title": "FCM Message",
"badge": 1,
"sound": "Default"
}
}
See Table 1 of the HTTP Server Protocol Document :
On iOS, use this field to represent content available in the APN payload. When a notification or message is sent and this is set to true, the inactive client application is woken up. On Android, data messages are awakened by the default app. Currently not supported in Chrome.
source to share