Quantcast
Channel: L.S.
Viewing all articles
Browse latest Browse all 31

Firebase, cloud messaging and problems receiving background notifications

$
0
0

2020-12-11 18:39:36.965 14746-14746/your.bundle E/RNFirebaseMsgReceiver: Background messages only work if the message priority is set to 'high'

This is something you can find in your adb logcat output when sending a push notification (cloud message) and your app is in background.

More specifically, the problem is mostly related to the idle status of your device.

This is explained in a dedicated Firebase doc, particularly in the “Using FCM to interact with your app while the device is idle” section.

If you are sending a message with curl, Postman and so on, you can add something to your JSON in order to set priority.

So a JSON body like this:

{ 
  "to": "token_here", 
  "notification": { 
    "title": "hey from Lorenzo", 
    "body": "great article dude!" 
  }, 
  "data": { 
    "body": "normal priority notification", 
    "title": "here we are", 
  }
}

becomes:

{ 
  "to": "token_here", 
  "android": {
        "priority": "high"
  },
  "priority": 10,
  "notification": { 
    "title": "hey from Lorenzo", 
    "body": "great article dude!" 
  }, 
  "data": { 
    "body": "normal priority notification", 
    "title": "here we are", 
  }
}

When performing your POST requesto to https://fcm.googleapis.com/fcm/send please remember to add a Content-type: application/json header and a Authorization header with value key=<server_key> that you can retrieve from the “Cloud Messaging” section of your project settings in the Firebase console.

The post Firebase, cloud messaging and problems receiving background notifications appeared first on L.S..


Viewing all articles
Browse latest Browse all 31

Trending Articles