php - php android推送通知设置高优先级
问题描述
我正在使用 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');
推荐阅读
- php - HTML 渲染延迟 - Laravel
- ios - 使用 Alamofire 解码 json 时出错
- json - Swift 4 可解码 var 可以是 Bool 或自定义类型
- android - 应用程序被杀死时Android BroadcastReceiver不工作
- node.js - 使用 node.js 的简单 AWS Lambda 函数
- java - Eclipse 部署组件找不到项目的条目
- bootstrap-4 - ng-bootstrap 依赖和警告
- java - Java Stream API 如何改进表达
- ipad - ios 9 ipad上的vuejs2应用程序黑屏
- sql - SQL 按块排序