Php 通过Firebase将推送通知从Laravel服务器发送到Android应用程序
是否可以通过基于laravel的仪表板而不是firebase控制台向android发送推送通知 如果可能,步骤是什么Php 通过Firebase将推送通知从Laravel服务器发送到Android应用程序,php,laravel,firebase,push-notification,firebase-cloud-messaging,Php,Laravel,Firebase,Push Notification,Firebase Cloud Messaging,是否可以通过基于laravel的仪表板而不是firebase控制台向android发送推送通知 如果可能,步骤是什么 谢谢。您可以为它创建帮助函数 试试这个:- function notifications($token=null,$title=null,$message=null,$user_id=null) { $path_to_firebase_cm = 'https://fcm.googleapis.com/fcm/send'; $fields = array(
谢谢。您可以为它创建帮助函数 试试这个:-
function notifications($token=null,$title=null,$message=null,$user_id=null)
{
$path_to_firebase_cm = 'https://fcm.googleapis.com/fcm/send';
$fields = array(
'to' => $token,
'notification' => array('title' => $title, 'body' => $message, 'sound' => 'default', 'click_action' => 'FLUTTER_NOTIFICATION_CLICK', 'icon' => 'fcm_push_icon'),
'data' => array('title' => $title, 'body' => $message, 'sound' => 'default', 'icon' => 'fcm_push_icon'),
);
$headers = array(
'Authorization:key=' . 'Your-fcm-key',
'Content-Type:application/json'
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $path_to_firebase_cm);
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($fields));
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
我会在这里检查一些问题和答案:例如,这个问题似乎有很长的路要走:就像这个: