From bd6675359b47be7f4835bdbfeed717e69732603d Mon Sep 17 00:00:00 2001 From: TCB13 Date: Tue, 19 Feb 2019 12:20:30 +0000 Subject: [PATCH 1/3] iOS: Allows sending of silent notifications Not send an `alert` to the server would result in a "silent" notification. Can be useful for notifications that the user shouldn't see. Read more about silent notifications here: https://stackoverflow.com/a/8949642/560745 Closes https://github.com/webwarejp/notificationhubs-rest-php/issues/20 --- src/NotificationHubsRest/Notification/AppleNotification.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/NotificationHubsRest/Notification/AppleNotification.php b/src/NotificationHubsRest/Notification/AppleNotification.php index 956b8db..385efa3 100644 --- a/src/NotificationHubsRest/Notification/AppleNotification.php +++ b/src/NotificationHubsRest/Notification/AppleNotification.php @@ -60,8 +60,10 @@ public function getPayload() } if (is_array($this->alert)) { - $alert = array_intersect_key($this->alert, array_fill_keys($this->supportedAlertProperties, 0)); - $payload += ['alert' => $alert]; + if (!empty($alert)) { + $alert = array_intersect_key($this->alert, array_fill_keys($this->supportedAlertProperties, 0)); + $payload += ['alert' => $alert]; + } } elseif (is_scalar($this->alert)) { $payload += ['alert' => $this->alert]; } else { From 4b734a1d9637cdd87e5a68c86618e4068e4bf6cb Mon Sep 17 00:00:00 2001 From: TCB13 Date: Tue, 19 Feb 2019 12:22:34 +0000 Subject: [PATCH 2/3] Fix code style --- src/NotificationHubsRest/Notification/AppleNotification.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NotificationHubsRest/Notification/AppleNotification.php b/src/NotificationHubsRest/Notification/AppleNotification.php index 385efa3..1f02425 100644 --- a/src/NotificationHubsRest/Notification/AppleNotification.php +++ b/src/NotificationHubsRest/Notification/AppleNotification.php @@ -61,7 +61,7 @@ public function getPayload() if (is_array($this->alert)) { if (!empty($alert)) { - $alert = array_intersect_key($this->alert, array_fill_keys($this->supportedAlertProperties, 0)); + $alert = array_intersect_key($this->alert, array_fill_keys($this->supportedAlertProperties, 0)); $payload += ['alert' => $alert]; } } elseif (is_scalar($this->alert)) { From fd1511c18745ccc1e11ca5d10f39c08dfaced158 Mon Sep 17 00:00:00 2001 From: TCB13 Date: Tue, 19 Feb 2019 12:43:28 +0000 Subject: [PATCH 3/3] Update AppleNotification.php --- src/NotificationHubsRest/Notification/AppleNotification.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NotificationHubsRest/Notification/AppleNotification.php b/src/NotificationHubsRest/Notification/AppleNotification.php index 1f02425..b6c5e12 100644 --- a/src/NotificationHubsRest/Notification/AppleNotification.php +++ b/src/NotificationHubsRest/Notification/AppleNotification.php @@ -60,7 +60,7 @@ public function getPayload() } if (is_array($this->alert)) { - if (!empty($alert)) { + if (!empty($this->alert)) { $alert = array_intersect_key($this->alert, array_fill_keys($this->supportedAlertProperties, 0)); $payload += ['alert' => $alert]; }