From 317ac19c52ec9232bc45475fec532f1bfa3cbac8 Mon Sep 17 00:00:00 2001 From: Kendrick Chan Date: Fri, 17 Aug 2018 03:34:46 +0800 Subject: [PATCH] Only allow ios push messages to go through APNS client service #162 --- src/Ramcar/MobileOSType.php | 14 ++++++++++++++ src/Service/APNSClient.php | 5 +++++ 2 files changed, 19 insertions(+) create mode 100644 src/Ramcar/MobileOSType.php diff --git a/src/Ramcar/MobileOSType.php b/src/Ramcar/MobileOSType.php new file mode 100644 index 00000000..67669294 --- /dev/null +++ b/src/Ramcar/MobileOSType.php @@ -0,0 +1,14 @@ + 'iOS', + 'ANDROID' => 'Android', + ]; +} diff --git a/src/Service/APNSClient.php b/src/Service/APNSClient.php index 4ac5c23d..2fc02fe9 100644 --- a/src/Service/APNSClient.php +++ b/src/Service/APNSClient.php @@ -4,6 +4,7 @@ namespace App\Service; use Mosquitto\Client as MosquittoClient; use App\Entity\JobOrder; +use App\Ramcar\MobileOSType; use Redis; class APNSClient @@ -43,6 +44,10 @@ class APNSClient foreach ($sessions as $sess) { + // check if mobile session is using an ios device + if ($sess->getOSType() != MobileOSType::IOS) + continue; + $push_id = $sess->getDevicePushID(); if ($push_id != null && strlen(trim($push_id)) > 0) $this->push($push_id, $message);