Below is the code for php in which i make a curl call to the GCM server:
//CODE TO SEND PUSH NOTIFICATION
define('API_ACCESS_KEY', 'XXXXXXXXXXXXXXXXXXXXX');
$i = 0;
$result1 = mysql_query("SELECT * FROM `my_devices`") or die($log->lwrite("Error" . mysql_error()));
while ($row2 = mysql_fetch_array($result1)) {
$i = $i + 1;
$msg = array(
'message' => $resultTextValue
);
$fields = array(
'registration_ids' => array($row2['gcmId']),
'data' => $msg
);
$headers = array(
'Authorization: key=' . API_ACCESS_KEY,
'Content-Type: application/json'
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://android.googleapis.com/gcm/send');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
$result = curl_exec($ch);
curl_close($ch);
}
My code is under development and has max of 10 device registered. So it take decent time to make send the notificaiton to all the device.
My concern is: when the app is deployed I will be having thousands of device to send the push notification. Won't it take a big amount of time for the push notification call?
I am new to PHP and copied the above code from some sample application.