简体   繁体   中英

Properly formed notification JSON

I using the following formatted json as my notification payload:

{
  "to":"[TOKEN]",
  "priority":"high",
  "content-available":true,
  "notification":{
    "ACTION":"false",
    "FIELD":"item1",
    "TITLE":"Title Here",
    "BODY":"This is the body"
  }
}

The push works and is caught by the target. The payload is received as below (which is fine):

{
  "data": {
    "gcm.notification.TITLE": "Title Here",
    "gcm.notification.ACTION": "false",
    "gcm.notification.FIELD": "item1",
    "gcm.notification.BODY": "This is the body"
  },
  "from": "[POINTER]",
  "priority": "high",
  "fcmMessageId": "07964eab-c1a5-46ac-a32d-c7c1a24fe28b"
}

BUT the notification display on my Android device is below:

在此处输入图像描述

I'm sure it's something easy, but I can't seem to find a good example of the proper format.

What am I missing?

Did you complete the code from a codelab? Because "Background Message..." looks like placeholders.

Whether or not it's from a codelab, please check the code in the service worker that listens to notifications in the background. Are you displaying notification data (title and body) that was obtained from the JSON payload or are you displaying some default placeholder text?

Please share the code of the service worker and other related code. If updating the code worked as I proposed, please edit this answer and add the working code. If your code however is correctly displaying notification data from Firebase Cloud Messaging, please indicate still, share the code and let's solve it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM