Advice and answers from the Realtime Team

Yes, you can!

Use the publishbatch endpoint of the Realtime Push Notifications REST API to send the same push notification message to a given list of channels, described as an array of strings.

Below you'll find a PHP example sending a push notification to channels channel1, channel2 and channel3 with a single HTTPS POST:

<?php
 
$curl = curl_init();
 
curl_setopt_array($curl, array(
  CURLOPT_URL => "https://ortc-mobilepush.realtime.co/mp/publishbatch",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_HTTPHEADER => array(
    "content-type: application/json"
  ),
  CURLOPT_POSTFIELDS => '{
      "applicationKey": "YOUR_REALTIME_APPKEY",
      "privateKey": "YOUR_REALTIME_PRIVATEKEY",
      "channels" : ["channel1", "channel2", "channel3"],
      "message" : "We have new articles for you",
      "payload" : "{
          \\"sound\\" : \\"default\\",
          \\"badge\\" : \\"2\\",
          \\"custom-property\\" : \\"value\\"
      }"
  }'
));
 
$response = curl_exec($curl);
$err = curl_error($curl);
 
curl_close($curl);
 
if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}


The list of channels is limited to 100 channels per request.

More details about the Push Notifications REST API can be found at http://messaging-public.realtime.co/documentation/starting-guide/mobilepush.html#custompush

Did this answer your question?