Closed GeoffreyPlitt closed 7 years ago
Try setting the notification
fields within the data
payload e.g.:
data: {
title: "Hello, World",
icon: "ic_launcher",
body: "This is a notification that will be displayed ASAP."
}
Ionic/Cordova had a bug that required this. Might be the same with React Native.
Solved. If anyone else has these issues, here's what fixed it for me:
{
collapseKey: 'demo',
priority: 'high',
contentAvailable: true,
timeToLive: 3,
data: {
key1: 'message1',
key2: 'message2'
},
notification: {
title: "Hello, World",
icon: "ic_launcher",
body: "This is a notification that will be displayed ASAP."
}
}
Thanks for sharing the solution @GeoffreyPlitt!
It seems to me that what was missing from the docs was something about the app having to be in background for notifications to autotrigger. We could add this! :smile:
I'm trying to use this library to send PN's to a phone that receives them via https://github.com/zo0r/react-native-push-notification. I'm testing on a real device, and I've got some GCM connection working, because I can see received message in my logs, but the notifications do not show in the UI (device's notification area), and I think it's because of a disparity in the documentation regarding the message schema.
I've tried several different example messages, pulled from your docs, their docs, or other places, and I'm showing the resulting message received. I'm pretty confused, and I can't find a way that seems to allow both "notification" and "data" parts through. In fact, it seems like "data" is the only part that goes through, which may explain my issue. As a side note, part of the problem seems to be that the data is sometimes collapsed from JSON to string, is that happening in your lib for some reason? As another side note, is this related to FCM vs GCM?
Each of the example messages below is sent to
sender.send(message, { registrationTokens: tokens }, ...)