E
E
evil0o2016-10-18 15:40:23
Google
evil0o, 2016-10-18 15:40:23

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

1 answer(s)
D
Dmitry Korolev, 2016-10-28
@Apathetic

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 question

Ask a Question

731 491 924 answers to any question