messaging.onMessage(function (payload) {
            console.log(payload);
            const notificationOption={
                body:payload.notification.body,
                icon:payload.notification.icon
            };
            if(Notification.permission === "granted"){ 
                var notification = new Notification(payload.notification.title,notificationOption);
                notification.onclick=function (ev) {
                    ev.preventDefault();
                    window.open(payload.notification.click_action,'_blank');
                    notification.close();
                }
            }
        });$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, htmlspecialchars_decode('https://fcm.googleapis.com/fcm/send'));
curl_setopt($ch, CURLOPT_POST, true);
$headers = [
	'Authorization: key=' . API_ACCESS_KEY,
	'Content-Type: application/json'
];
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 2);
$fields = [
	'to' => 'userAgentToken',
	'notification' => [
	'body' => 'Some body text',
	'title' => 'Some title text'
]];
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
curl_exec($ch);
curl_close($ch);