PHP的Android推送通知设置高优先级

时间:2019-03-04 06:22:05

标签: php android push-notification

我正在使用PHP从浏览器向Android设备发送通知。当我退出注销通知后启动应用程序但如果我杀死应用程序通知不来时。任何解决方案。

 public function send_android($target, $fields) {
    $apiKey = 'XXXXXXXXX';
    $headers = array("Content-Type:" . "application/json", "Authorization:key=" . $apiKey);

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($ch, CURLOPT_URL, "https://fcm.googleapis.com/fcm/send");
    curl_setopt( $ch, CURLOPT_POST, true );
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
     curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
    $result = curl_exec($ch);
    curl_close($ch);
}

1 个答案:

答案 0 :(得分:0)

您需要在名为"priority"的字段数组中发送额外的密钥,其值将为“ high”。 因此您的fields数组将与...相同。

$fields = array('to' => $token, 'notification' => $notification,'priority'=>'high');