繁体   English   中英

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

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM