Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

satheeshkumarj's avatar

How to add Action Url in Firebase push notification

How to add Action URL in Firebase push notification with Laravel

 $firebaseToken = $deviceToken;
      
        $SERVER_API_KEY = env('FCM_SERVER_KEY');
    
        $data = [
            "to" => $firebaseToken,
            "notification" => [
                "title" => $notificationTitle,
                "body" => $notificationMessage, 
                "image" => $companyLogo,
                "url" => $actionURL,
            ]
        ];
        $dataString = json_encode($data);
      
        $headers = [
            'Authorization: key=' . $SERVER_API_KEY,
            'Content-Type: application/json',
        ];
      
        $ch = curl_init();
        
        curl_setopt($ch, CURLOPT_URL, 'https://fcm.googleapis.com/fcm/send');
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $dataString);
                 
        $response = curl_exec($ch);

This is my code. getting push notification , But when clicking it redirects to App home page not to the URL given

0 likes
0 replies

Please or to participate in this conversation.