Answer the question
In order to leave comments, you need to log in
How to send information with push notification in Firebase Cloud Messaging Server?
The notification is being sent, but I'm unable to send information with them in data
curl -X POST --header "Authorization: key=Achhhhhhhhhh" --Header "Content-Type: application/json" https://fcm.googleapis.com/fcm /send -d "{\"data\":{\"title\":\"abc\"}, \"to\":\"fhhhhhhhhhhhh0\"}"
self.addEventListener('push', function(event) {
console.log('Push message', event);
var data = {};
if (event.data) {
data = event.data.json();
console.log(data);
}
event.waitUntil(
self.registration.showNotification({
'body': 'The Message',
'icon': 'images/icon.png'
}));
});
Answer the question
In order to leave comments, you need to log in
Do not send data via curl. To transfer additional data along with a push notification, you need to use a server, encrypt the data on it with the keys received from the subscription, and then send it.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question