Closed Piero87 closed 4 years ago
Hi, Has you may notice in the Readme, you must create a channel in order to receive / trigger notifications. Regards
Hello @Dallas62, I'm sorry I miss that part in my first comment, I already tried also that, I do this:
onRegister: async data => {
console.log("TOKEN:", data);
try {
if (Platform.OS === 'android') {
PushNotification.createChannel(
{
channelId: "rn-push-notification-channel-id-4-300", // (required)
channelName: "Beta Android Push", // (required)
channelDescription: "Beta Android Push", // (optional) default: undefined.
soundName: "default", // (optional) See `soundName` parameter of `localNotification` function
importance: 4, // (optional) default: 4. Int value of the Android notification importance
vibrate: true, // (optional) default: true. Creates the default vibration patten if true.
},
(created) => console.log(`createChannel returned '${created}'`) // (optional) callback returns whether the channel was created, false means it already existed.
);
}
} catch (error) {
console.log(error);
}
},
But it's not working, do the same, only notification from the console log and nothing on the device
You are sending data-only notification, this will not trigger a visible notification. Please refer to the Firebase documentation for the notification payload. Regards
@Dallas62 Yes! it was that! thank you very much! About the channel name is arbitrary? I can choose my own just by changing your default one? I have also another question, my implementation of PushNotification.createChannel is correct?
You can use your own values for each parameter, keep then meaningful for the user. The channel can be created at application startup, you are not forced to wait for registration or filter by OS.
@Dallas62 Thank you very much!
You are sending data-only notification, this will not trigger a visible notification. Please refer to the Firebase documentation for the notification payload. Regards
I think I have the same problem (data-only notification meaning no visible notification), but I can't seem to find info on what extra information to add to the payload to rectify this. EDIT - found it here
I'm also interested in which node module is best to use to trigger remote push notifications on the server with FCM. At the moment I'm using the sendMulticast()
method of node firebase-admin
- is this what you would recommend?
Many thanks in advance
EDIT: I went poking around in the types (should've done so straight away), and have found that the payload should have the following structure:
interface BaseMessage {
data?: {
[key: string]: string;
};
notification?: Notification;
android?: AndroidConfig;
webpush?: WebpushConfig;
apns?: ApnsConfig;
fcmOptions?: FcmOptions;
}
plus the tokens array.
Unfortunately, even with this I only get the data message and not a notification
You are sending data-only notification, this will not trigger a visible notification. Please refer to the Firebase documentation for the notification payload. Regards
I think I have the same problem (data-only notification meaning no visible notification), but I can't seem to find info on what extra information to add to the payload to rectify this. EDIT - found it here
I'm also interested in which node module is best to use to trigger remote push notifications on the server with FCM. At the moment I'm using the
sendMulticast()
method of nodefirebase-admin
- is this what you would recommend? Many thanks in advanceEDIT: I went poking around in the types (should've done so straight away), and have found that the payload should have the following structure:
interface BaseMessage { data?: { [key: string]: string; }; notification?: Notification; android?: AndroidConfig; webpush?: WebpushConfig; apns?: ApnsConfig; fcmOptions?: FcmOptions; }
plus the tokens array.
Unfortunately, even with this I only get the data message and not a notification
Seems as though I have the same behaviour as #1602 - likely related to the fact the device I'm using for testing is running Android 7 (unable to update).
Bug
Hello, I'm using this library to receive push notification in my react native app, on iOS all working fine instead on Android I don't see any notification but I see only in the terminal with a console log inside
onNotification
callback, I show you how:And in the console I see this:
NOTIFICATION: {"data": {"badge": "1", "message": "test test test", "sound": "default"}, "finish": [Function finish], "foreground": true, "id": "1319931916", "userInteraction": false}
or this:
NOTIFICATION: {"data": {"badge": "1", "message": "test test test", "sound": "default"}, "finish": [Function finish], "foreground": false, "id": "-1095461832", "userInteraction": false}
But in the device when the app is open, in background or closed I don't see any banner or icon nothing. I searched a lot in the issues of this library and I find something similar like: https://github.com/zo0r/react-native-push-notification/issues/1496 or https://github.com/zo0r/react-native-push-notification/issues/1395, all talking about setup a channel, I have tried also that with no luck. I show you my code:
AndroidManifest.xml
Can anyone help me please? I'm going crazy!
Environment info
"@react-native-community/push-notification-ios": "^1.5.0", "react-native-push-notification": "^6.1.1", "react-native": "^0.63.3",