I have some problems with push notification with php & android.
When I make new order with android app after it insert to database and before response to android app, I start a service whit bellow code:
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, "token=" . config('app.passwords.service_token'));
curl_setopt($curl, CURLOPT_TIMEOUT, 1);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 1);
curl_setopt($curl, CURLOPT_NOSIGNAL, 1);
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_FRESH_CONNECT, true);
$response = curl_exec($curl);
curl_close($curl);
This code will send the push notification.
I have problem with curl timeout. In this code it is 1 second. In most cases, the request sent with curl takes more time and is not sent push as a result. If we increase the timeout value, the answer will be delayed to the android app and problems will be on the Android side.
What do you suggest? What should I do?