We are trying to send a desktop notification calling the FCM rest api via a php service.
We call the https://fcm.googleapis.com/fcm/send service, passing the following payload:
"data" => [
"notification" => [
"title" => $content->title,
"body" => "notification body",
"icon" => url('assets/images/logo_3.png'),
],
"webpush" => [
"headers" => [
"Urgency" => "high",
],
"fcm_options" => [
"link" => url($content->url)
]
],
],
The notification is received in desktop (tested on windows 10) but when we click on the popup the link is not opened in the browser.
What are we doing wrong?
It turns out that we must use click_action field, like this:
"notification" => [
"title" => $content->title,
"body" => "body",
"icon" => "assets/icon.png",
"click_action" => "https://www.example.com",
]
Docs here:https://firebase.google.com/docs/cloud-messaging/http-server-ref
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With