且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

收到推送通知时如何自动打开应用程序?

更新时间:2023-02-27 08:47:44

这是需要从后端处理的东西,

This is something need to handle from backend,

这是您当前正在使用的示例有效负载, { "message":{ "token":"bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1...", "notification":{ "title":"Portugal vs. Denmark", "body":"great match!" } } }

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.

详细信息,您可以在此处.

现在,要始终控制您的通知,您需要像下面这样的有效负载,

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" } } }

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

区别在于您需要发送数据有效负载,而不是从后端发送通知poayload.

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