Firebase Expandable Notification Show image when app is in background

前端 未结 12 2084
深忆病人
深忆病人 2020-12-23 14:19

I am implementing FCM notifications in Android, but how does notifications differ depending on the app status (background vs. foreground)?

12条回答
  •  误落风尘
    2020-12-23 14:41

    Messages, that contain both notification and data payload (like your example sent with Postman) are automatically displayed to end-user devices by the FCM library. And this does not include (big) images.

    I guess there are two possibilities for you:

    1. Try what Rashmi Jain suggested. However, this solution could work right now and stop working tomorrow, if the Firebase library is updated (and thus the implementation of the message handling)

    2. Send a data message with Postman. You may not fill the notification object in the JSON therefore, so it could look something like this:

      {
        "message": {
          "token":"bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1...",
          "data":{    
            "title" : "Awesome title",
            "body"  : "Your awesome push notification body",
            "image"  : "your_image_url"
          }
        }
      }
      

    I would prefer the 2nd option. Good luck!

提交回复
热议问题