Send push notifications with web component

Good day.
Does anyone know how to use this api please?

I would like to test if it works to send push notifications through the web component.

To send notifications through Firebase Cloud Messaging (FCM), you need to include the Server Key in the headers of the HTTP request to authenticate the request. Here are the key headers you need to include:

Authorization Header:

Header: Authorization
Value: key=YOUR_SERVER_KEY
Replace YOUR_SERVER_KEY with the actual Firebase server key. This key is located in the Firebase console, in the Project Settings > Cloud Messaging section.

Content-Type Header:

Header: Content-Type
Value: application/json
These are the two main headers you should include in your HTTP POST request when sending notifications to FCM. Here is an example with cURL:

curl -X POST -H "Authorization: key=YOUR_SERVER_KEY" -H "Content-Type: application/json" -d '{
  "to": "token_del_dispositivo",
  "notification": {
    "title": "New news",
    "body": "¡Read the latest exciting news!"
  },
  "data": {
    "click_action": "OPEN_NEWS",
    "news_url": "https://mynewsapp.com/news?id=123",
    "source": "notification"
  }
}' "https://fcm.googleapis.com/fcm/send"

Make sure to replace YOUR_SERVER_KEY with your actual Firebase server key and “device_token” with the registration token of the device you want to send the notification to.

Remember that the server key must be kept secure and should not be shared publicly. If at any time you suspect that the key has been compromised, it is recommended to regenerate it in the Firebase console to maintain the security of your application.

Can anyone translate into blocks?

1 Like

You may follow this guide to convert your curl request to blocks.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.