单击通知后如何访问通知数据(firebase云消息传递) [英] How to access notification data after clicking on notification (firebase cloud messaging)
问题描述
我已经为我的 react-native应用
实现了 firebase云消息传递
,现在我可以发送和接收通知.但是,现在我想在单击它之后立即获取像 messages
这样的 Notifications Data
.
I have implemented firebase cloud messaging
for my react-native app
and now I am able to send and receive Notifications.
But now I want to get the Notifications Data
like messages
, right after clicking on it.
为什么我需要这个?
因为我有一个简单的聊天应用程序,并且假设我有三个房间, room1,room2,room3
.
Because I have A simple chat app, and suppose I have three rooms, room1, room2, room3
.
现在我的 App
已关闭,并且我从 room1
收到了 Notification
,然后单击该按钮,这时我希望它可以打开我的应用程序,然后导航到 room1聊天框
,以及其他会议室通知.
Now my App
is closed and I receive Notification
from room1
, then I click on that, At this time I expected it open my app and navigate to the room1 chatbox
, and the other rooms notifications too.
有帮助吗?
注意:我正在使用react-native-firebase v6
推荐答案
Cloud Messaging仅用于从手机上的服务器发送消息.
Cloud Messaging is only used to send messages from a server on the phone.
之前,在Firebase 5上,我们有一个名为通知"的程序包,通过该程序包,我们可以在单击数据时管理数据的拦截.
Before, on firebase 5, we had a package called "notifications" which allowed us to manage the interception of data when you clicked on it.
自Firebase 6起,此软件包已不存在(嗯,以某种方式它将成为付费服务,并且该服务称为Notifee,但仍在测试中).
Since Firebase 6, this package doesn't exist anymore (well, in a way it will become paying and this service is called Notifee but it is still in test).
您必须使用外部程序包(例如react-native-push-notifications),使您可以拦截推送通知数据.
You have to use external packages such as react-native-push-notifications which allows you to intercept push notifications data.
这篇关于单击通知后如何访问通知数据(firebase云消息传递)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!