Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FCM link not working in desktop notification

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?

like image 955
brazorf Avatar asked Nov 17 '25 03:11

brazorf


1 Answers

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

like image 59
brazorf Avatar answered Nov 19 '25 18:11

brazorf