Aug 27, 2022
0
Level 1
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
Please or to participate in this conversation.