How to automatically open app when receive push notification?

后端 未结 3 625
长发绾君心
长发绾君心 2021-01-13 19:22

I want to automatically open app when receive push notification. I\'ve tried but it still does not work as I expected. This code below is work when the app is active or in M

3条回答
  •  逝去的感伤
    2021-01-13 19:57

    This is something need to handle from backend,

    Here is a sample payload you are using right now, { "message":{ "token":"bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1...", "notification":{ "title":"Portugal vs. Denmark", "body":"great match!" } } }

    Which will only give you control to manipulate and do some action when your app will be in foreground otherwise just raise notification.

    In details you can check here.

    Now, To always get control over your notification, you need payload like following,

    { "message":{ "token":"bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1...", "data":{ "Nick" : "Mario", "body" : "great match!", "Room" : "PortugalVSDenmark" } } }

    The difference is you need to send data payload instead of notification poayload from backend.

提交回复
热议问题