【发布时间】:2017-10-21 12:16:39
【问题描述】:
我正在尝试使用 firebase 云消息传递和 react-native 应用程序来实现 react-native-fcm。
我主要关注Android
react-native@0.48.0
react-native-fcm@10.0.2
OS: Android - Emulator - 7.0.2
当我的应用程序处于前台时,它运行良好,我在此函数中接收数据
FCM.on(FCMEvent.Notification, async (notif) => {
我什么都能搞定
但是当应用程序在后台时,收到通知,但是当我点击横幅时,应用程序进入前台,触发相同的功能,但notif对象不同,并且不包含我的数据。
当应用程序被杀死时,也会收到通知,但是当我点击横幅时,应用程序启动,
FCM.getInitialNotification()
被触发,并且我的通知对象也不包含数据,与后台相同的行为
我正在使用 firebase web 界面的 node-gcm 库测试消息的格式,但没有任何效果。
这是我的信息示例,但我尝试了很多组合:
let message = new gcm.Message({
priority: 'high',
content_available: true,
timeToLive: 3,
data: {
key1: 'message1',
key2: 'message2'
},
notification: {
title: "Hello, World",
icon: "ic_launcher",
body: "This is a notification that will be displayed if your app is in the background."
},
custom_notification: {
key1: 'message1',
key2: 'message2'
}
});
在这些情况下,我应该如何继续发送和接收数据?因为快把我逼疯了。
如果您需要更多数据,请索取 :)
谢谢!!
【问题讨论】:
-
你有没有得到任何解决方案,我也面临同样的问题,如果你得到请在这里添加你的答案。
-
这是一个与在 android 代码中使用两个意图相关的问题(我将另一个用于启动屏幕):在我只留下一个意图的代码时,它遵循良好的行为
-
stackoverflow.com/questions/49026676/… 如果您有任何解决方案,请检查一次。我没有在 android 部分使用任何 Splash 活动。
标签: react-native push-notification firebase-cloud-messaging android-notifications react-native-fcm