2017-05-11 58 views
0

我有一個觸發使用下面的代碼推送通知的發送到相應設備的CakePHP API服務器:CakePHP的API服務器響應時間和FCM推送通知

 $url = 'https://fcm.googleapis.com/fcm/send'; 
     $headers = array(
       'Authorization:key = <<Authorization Key>', 
       'Content-Type: application/json' 
      ); 
     $ch = curl_init(); 
     curl_setopt($ch, CURLOPT_URL, $url); 
     curl_setopt($ch, CURLOPT_POST, true); 
     curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); 
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
     curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); 
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 
     curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data)); 
     $result = curl_exec($ch); 
     if ($result === false){ 
      die('Curl failed: '. curl_error($ch));  
     } 
     curl_close($ch); 

當端點調用向服務器發出並觸發上面的代碼,由於它的執行有一個延遲(上面的代碼工作正常)。

我最好喜歡這個時候消除,因爲代碼不會影響響應消息。有沒有一種管理推送通知的方式可以消除端點請求上的響應時間?

回答