单独的通知不会出现在订阅主题的同一设备上
Separate Notifications do not appear on a same device subscribed to a topic
当我通过 api 使用 FCM 订阅主题循环推送多个通知时,之前的通知在我的 android 设备上被新通知取代。有没有办法分别推送多个通知。我正在使用 PHP Curl 请求。
foreach ($result as $item)
{
$message = array
(
'body' => "Details:".$item['tagid'],
'title' => "Tag:".$item['event'],
'key1' => "NotificationActivity"
);
$fields = array(
'to' => '/topics/all',
'data' => array
(
'message' => $message
),
);
$headers = array
(
'Authorization: key=' . API_ACCESS_KEY,
'Content-Type: application/json'
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://fcm.googleapis.com/fcm/send');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
$result = curl_exec($ch);
curl_close($ch);
}
我的 Firebase 服务出现问题。不根据 id 识别通知。
问题是,我在 id 字段中传递了 0。
notificationManager.notify(0 /* ID of notification */, notificationBuilder.build());
设置每个通知的唯一 ID 后,它起作用了:
notificationManager.notify(id /* ID of notification */, notificationBuilder.build());
当我通过 api 使用 FCM 订阅主题循环推送多个通知时,之前的通知在我的 android 设备上被新通知取代。有没有办法分别推送多个通知。我正在使用 PHP Curl 请求。
foreach ($result as $item)
{
$message = array
(
'body' => "Details:".$item['tagid'],
'title' => "Tag:".$item['event'],
'key1' => "NotificationActivity"
);
$fields = array(
'to' => '/topics/all',
'data' => array
(
'message' => $message
),
);
$headers = array
(
'Authorization: key=' . API_ACCESS_KEY,
'Content-Type: application/json'
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://fcm.googleapis.com/fcm/send');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
$result = curl_exec($ch);
curl_close($ch);
}
我的 Firebase 服务出现问题。不根据 id 识别通知。
问题是,我在 id 字段中传递了 0。
notificationManager.notify(0 /* ID of notification */, notificationBuilder.build());
设置每个通知的唯一 ID 后,它起作用了:
notificationManager.notify(id /* ID of notification */, notificationBuilder.build());