From 0eef2449e83c672b8f52efc188b87fbb9d42aeb0 Mon Sep 17 00:00:00 2001 From: Ramon Gutierrez Date: Wed, 19 Jul 2023 16:14:49 +0800 Subject: [PATCH] Fix duplicate fcm notification issue #746 --- src/Service/FCMSender.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Service/FCMSender.php b/src/Service/FCMSender.php index 8130fe1a..412ba6af 100644 --- a/src/Service/FCMSender.php +++ b/src/Service/FCMSender.php @@ -71,9 +71,9 @@ class FCMSender foreach ($sessions as $sess) { $device_id = $sess->getDevicePushID(); - if (!empty($device_id)) { + if (!empty($device_id) && !isset($device_ids[$device_id])) { // send fcm notification - $device_ids[] = $device_id; + $device_ids[$device_id] = true; } } @@ -87,7 +87,7 @@ class FCMSender $data['jo_status'] = $job_order->getStatus(); // send fcm notification - $result = $this->send($device_ids, $this->translator->trans($title), $this->translator->trans($body), $data); + $result = $this->send(array_keys($device_ids), $this->translator->trans($title), $this->translator->trans($body), $data); return $result; }