Xamarin Forms Android not receiving Push notifications when closed

前端 未结 1 1978
清歌不尽
清歌不尽 2021-01-23 04:15

I am following this walkthrough for creating push notifications into a Xamarin forms app

https://docs.microsoft.com/en-us/azure/notification-hubs/notification-hubs-andro

相关标签:
1条回答
  • 2021-01-23 04:40

    try to put JSON key 'notification' in your request to firebase API but instead use 'data'

    {
     "to": "/topics/journal",
     "notification": {
     "title" : "title",
     "text": "data!",
     "icon": "ic_notification"
      }
    }
    

    in this case,these messages trigger the onMessageReceived() callback only when your app is in foreground

    {
     "to": "/topics/dev_journal",
     "data": {
       "text":"text",
       "title":"",
       "line1":"Journal",
       "line2":"刊物"
      }
    }   
    

    in this case,theses messages trigger the onMessageReceived() callback even if your app is in foreground/background/killed

    but this is a topic that depends also on the device and that FCM has no total control over.

    the more you could refer to https://stackoverflow.com/a/37845174/10768653

    and https://stackoverflow.com/a/43131488/10768653

    0 讨论(0)
提交回复
热议问题