[英]How to send Chrome push notification to mulitple device
I want to send chrome push notifications to the registered user.I followed this link https://developers.google.com/web/fundamentals/getting-started/push-notifications/?hl=en to develop a basic push notification and it works fine. 我想向注册用户发送Chrome推送通知。我点击了此链接https://developers.google.com/web/fundamentals/getting-started/push-notifications/?hl=zh-CN开发基本的推送通知,工作正常。
For now, I am sending notification to users by running curl script with subscription id in the terminal. 目前,我正在通过在终端中运行带有订阅ID的curl脚本向用户发送通知。 Using this I can send notification to a single user.
使用此我可以将通知发送给单个用户。 I want to send to multiple users.
我想发送给多个用户。 How can I achieve this?
我该如何实现?
Try this :- 尝试这个 :-
<?php
$data = ["registration_ids" => ["regid1","regid2",...,"regidn"]];
$dataString = json_encode($data);
$curl = curl_init('https://android.googleapis.com/gcm/send');
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($curl, CURLOPT_POSTFIELDS, $dataString);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, [
'Content-Type: application/json',
'Authorization: key=YOUR_API_KEY'
]);
$result = curl_exec($curl);
print_r($result);
?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.