Firebase onMessageReceived not called when app in background

前端 未结 26 3313
粉色の甜心
粉色の甜心 2020-11-22 02:32

I\'m working with Firebase and testing sending notifications to my app from my server while the app is in the background. The notification is sent successfully, it even appe

26条回答
  •  南旧
    南旧 (楼主)
    2020-11-22 03:03

    Check the answer of @Mahesh Kavathiya. For my case, in server code has only like this:

    {
    "notification": {
      "body": "here is body",
      "title": "Title",
     },
     "to": "sdfjsdfonsdofoiewj9230idsjkfmnkdsfm"
    }
    

    You need to change to:

    {
     "data": {
      "body": "here is body",
      "title": "Title",
      "click_action": "YOUR_ACTION"
     },
    "notification": {
      "body": "here is body",
      "title": "Title"
     },
     "to": "sdfjsdfonsdofoiewj9230idsjkfmnkdsfm"
    }
    

    Then, in case app in Background, the default activity intent extra will get "data"

    Good luck!

提交回复
热议问题