1

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.

For now, I am sending notification to users by running curl script with subscription id in the terminal. Using this I can send notification to a single user. I want to send to multiple users. How can I achieve this?

Vamsi
  • 423
  • 1
  • 5
  • 19
  • [Send Push Notification](http://stackoverflow.com/questions/36506934/failed-to-send-push-notification/36507747#36507747) – Owais Aslam Oct 04 '16 at 08:04

1 Answers1

2

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);
        ?>
R C
  • 461
  • 4
  • 17