小编yoh*_*ndo的帖子

如何向 firebase 推送通知发送附加数据

我能够使用 php 和 curl 向 Ios/Android 发送推送通知。现在我想更新代码以发送其他参数,例如 user_id、name。这样我就可以在前端获取这些信息。但我不'不知道如何传递这些数据。有人可以帮助我吗?

function sendPushNotification($token,$push_notification_title=null,$push_notification_body=null){

$url = env('FIREBASE_URL');
$serverKey = env('FIREBASE_SERVER_KEY');
$title = $push_notification_title??"New Physician Review";
$body = $push_notification_body??"Your case has been reviewed";

$notification = array('title' => $title, 'text' => $body, 'body' => $body, 'sound' => 'default', 'badge' => '1');
$arrayToSend = array('to' => $token, 'notification' => $notification, 'priority' => 'high', 'data' => $notification, 'content_available' => true);

$json = json_encode($arrayToSend);
$headers = array();
$headers[] = 'Content-Type: application/json';
$headers[] = 'Authorization: key=' . $serverKey;


$ch = …
Run Code Online (Sandbox Code Playgroud)

php curl laravel firebase firebase-cloud-messaging

3
推荐指数
1
解决办法
3985
查看次数

标签 统计

curl ×1

firebase ×1

firebase-cloud-messaging ×1

laravel ×1

php ×1