Firebase Push Notification Php

Merhaba Mobil uygulamar için olmazsa olmaz push bildirimleri için firebase php post request örneği;

define(‘API_ACCESS_KEY’, ‘API_KEY_BURAYA’);
$fcmUrl = ‘https://fcm.googleapis.com/fcm/send’;
$token = ‘TOKEN_BURAYA’;

$notification = [
‘title’ => “TEST BILDIRIM”,
‘body’ => “MERHABA BU TEST BILDIRIMDIR”,
‘icon’ => ‘default’,
‘sound’ => ‘default’
];
$extraNotificationData = [“message” => $notification, “moredata” => ”];

$fcmNotification = [
//’registration_ids’ => $tokenList, //birden çok token’a göndermek için
‘to’ => $token, //sadece 1 token için
‘notification’ => $notification,
‘data’ => $extraNotificationData
];

$headers = [
‘Authorization: key=’.API_ACCESS_KEY,
‘Content-Type: application/json’
];

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $fcmUrl);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fcmNotification));
$result = curl_exec($ch);
curl_close($ch);
if ($result) {
echo “Bildirim gönderildi bildirim Mesaj Id:”.$result;

} else {
echo “Bildirim gönderilemedi!”;
}