php - Firebase 推送通知 - 未接收
问题描述
我有 PHP codeigniter 作为后端服务器将推送通知发送到 iOS 和 Android 设备。数据库中有超过 500 个用户使用他们的 FCM 令牌。在发送通知时,某些设备有时会收到通知,而其他设备每次都会收到通知。
public function sendNotification($data) {
$apiKey = FCM_KEY;
$client = new Client();
$client->setApiKey($apiKey);
$client->injectHttpClient(new \GuzzleHttp\Client());
$note = new Notification($data['subject'], $data['message'], $is_silent);
$message = new Message();
$message->addRecipient(new Device($data['token']));
$note->setIcon('notification_icon_resource_name')
->setBadge($data['total_notification_count'])
->setAndroidPriority('high')
->setSound('default')
->setContentAvailable(1);
$message->setNotification($note);
$message->setPriority(10);
$message->setData(array('title' => $data['subject'], 'body' => $data['message']));
$response = $client->send($message, $data['type']);
return $response->getStatusCode();
}
是否有任何机制可以从 FCM 获取通知失败并仅为这些用户重试那些通知发送。
解决方案
推荐阅读
- java - 使用 Process.StartInfo 编译 Java 程序时出现错误“系统找不到指定的文件”
- lua - LUA 从 if 语句到 if elseif 语句循环
- c# - 我收到一个错误,因为我无法在另一个对象中实例化一个对象
- json - Play2 Scala:将 Json 反序列化为对象列表
- angular - 在primeng 7.0.5版中加载数据时,多选onChange事件不起作用
- r - R irlba 稀疏数据表示
- excel - Excel SUMIF 使用带有 OR 的多个范围?
- excel - 自定义透视行以平均透视内的透视数据
- symfony - Twig 变量范围包括,宏
- python - pynput keyboard.type() 干扰