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?

+3


source to share


2 answers


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.

+3


source


Make sure you enable background modes for remote notifications. If not, click on the workspace and turn on features and turn on backgrounds.



enter image description here As shown in the picture of the last option for remote notification, check this option

0


source







All Articles