Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 15970

Firebase FCM send the notification with PHP but without link

$
0
0

i'm trying to send push notifications with FCM in PHP curl but the notification goes, is received, but when i click... the link does not open anything or even open the chrome/edge... Am i missing something?

The code:

        //receive user token        $token_user = $row['token'];        $credential = new ServiceAccountCredentials("https://www.googleapis.com/auth/firebase.messaging",            json_decode(file_get_contents($DIR . "cron/file.json"), true)        );        $token = $credential->fetchAuthToken(HttpHandlerFactory::build());        $ch = curl_init("https://fcm.googleapis.com/v1/projects/myproject/messages:send");        curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json','Authorization: Bearer ' . $token['access_token']        ]);        $data = ["message" => ["token" => "$token_user","notification" => ["title" => "Breaking News...."                ],"webpush" => ["headers" => ["image" => 'https://foo.bar.pizza-monster.png'                    ],"fcm_options" => ["link" => "https://google.com"                    ]                ]            ]        ];        curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);        $response = curl_exec($ch);        curl_close($ch);        echo $response;

I tried change the url to relative path, to https. Tried with the old payload form and the newest but, nothing works.


Viewing all articles
Browse latest Browse all 15970

Latest Images

Trending Articles



Latest Images