The following code works, but it sends only around 1000 push notifications after the timeout of 5 minutes, I have set ini_set('max_execution_time', 30000);
but not working also set in PHP.ini file
function iphone_push(device<sub>token</sub>, message = "", title = "", badge = 1)
{
try {
$write_data = "";
$streamContext = stream_context_create();
stream_context_set_option($streamContext, 'ssl', 'local_cert', $this->certificate_path);
$push_arr = array(
"alert" => $title,
"sound" => "push_sound.wav",
"badge" => 1,
);
$payload = array();
$payload['aps'] = $push_arr;
$payload = json_encode($payload);
for ($i = 0; $i < count($device_token); $i++)
{
$fp = stream_socket_client($this->apns_host, $error, $errorString, 60, STREAM_CLIENT_CONNECT, $streamContext);
if ($device_token[$i] == "")
continue;
$apnsMessage = chr(0) . Chr(0) . Chr(32) . Pack('H*', str_replace(' ', '', $device_token[$i])) . Chr(0) . Chr(strlen($payload)) . $payload;
fwrite($fp, $apnsMessage);
}
fclose($fp);
} catch (Exception $e) {
write_log("ipush", $e->getMessage());
}
return success_res("iphone_push_sent");
}