简体   繁体   English

如何将Chrome推送通知发送到多个设备

[英]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.

相关问题 如何将推送通知从 Firebase 发送到 iOS 设备上的 web 应用程序? - How to send push notification from Firebase to web app on iOS device? 如何在Laravel中使用Kreait / Firebase云消息向多个设备发送发送推送通知 - How to send send push notification to multiple device using kreait/firebase cloud message in laravel 设备令牌无效时将推送通知发送到ios设备崩溃 - Send push notification to ios device crash when device token is invalid Android,向多个用户发送推送通知 - Android, sending push notification to mulitple users 如何在Laravel 5.1中使用AWS SNS将推送通知从Web发送到iOS和android设备? - How to send push notification from web to iOS and android device using AWS SNS in Laravel 5.1? 如何从onesignal发送推送通知,将设备ID存储在数据库中-Cordova应用 - how to send push notification from onesignal the device id's are stored in database - cordova app 向APP发送推送通知,无需设备令牌或注册ID - Send push notification to APP without device token or register id 将 Android 推送通知发送到多个设备的 PHP 代码 - PHP code to send Android push notification to multiple device 使用APNS和使用PHP的DataService向iOS设备发送推送通知 - Send Push notification to IOS Device using APNS and DataService using PHP 推送通知在设备上不起作用 - push notification is not working on device
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM