CodeIgniter Forums

Full Version: Run php script without hanging
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have function that send push notification to users
When i use this function when user use it,it take 2 second for send push and user give result
While after execute send_push function,user have to receive result quickly
Do anyone have idea?

PHP Code:
function send_push($topic,$data,$is_android TRUE) {

//shell_exec("php test.php $topic '$data' > /dev/null 2>/dev/null &");

$api    =    config_item('firebase_api');

$fields = array
'to'                 => "/topics/$topic",
'content_available'    =>    TRUE,
'data'                => $data

        if (!
$fields['notification']    =    $data;
$headers = array
'Authorization: key=' $api,
'Content-Type: application/json'

$ch curl_init();
curl_setopt$ch,CURLOPT_URL'' );
curl_setopt$ch,CURLOPT_POSTtrue );
curl_setopt$ch,CURLOPT_HTTPHEADER$headers );
curl_setopt$ch,CURLOPT_RETURNTRANSFERtrue );
curl_setopt$ch,CURLOPT_SSL_VERIFYPEERfalse );
curl_setopt$ch,CURLOPT_POSTFIELDSjson_encode$fields ) );
$result curl_exec($ch );
curl_close$ch );