[英]php android push notifications set high priority
我正在使用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);
}
您需要在名為"priority"
字段數組中發送額外的密鑰,其值將為“ high
”。 因此,您的字段數組將與...相同
$fields = array('to' => $token, 'notification' => $notification,'priority'=>'high');
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.