From bc232c50a1da67efabd5ddb056e826e7c034df9a Mon Sep 17 00:00:00 2001 From: Dejan Date: Sat, 4 Apr 2020 15:51:27 +0200 Subject: [PATCH 1/2] Throw exception when routeNotificationForFirebase is not defined --- src/FirebaseChannel.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/FirebaseChannel.php b/src/FirebaseChannel.php index f2873aa..5e87d3e 100644 --- a/src/FirebaseChannel.php +++ b/src/FirebaseChannel.php @@ -49,6 +49,10 @@ public function send($notifiable, Notification $notification) { $devices = $notifiable->routeNotificationFor('firebase'); + if (!method_exists($notifiable, 'routeNotificationForFirebase')) { + throw new Exception('Firebase notification method "routeNotificationForFirebase" is not implemented but was called for ' . $notifiable->getTable()); + } + if (empty($devices)) { return; } From 68e46fcfebbe4d6d0278d1ce6801671b6243b7f7 Mon Sep 17 00:00:00 2001 From: Dejan Date: Sat, 4 Apr 2020 15:52:07 +0200 Subject: [PATCH 2/2] devices expects an array and fails silently if string provided --- src/FirebaseChannel.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/FirebaseChannel.php b/src/FirebaseChannel.php index 5e87d3e..b4b09ed 100644 --- a/src/FirebaseChannel.php +++ b/src/FirebaseChannel.php @@ -57,6 +57,10 @@ public function send($notifiable, Notification $notification) return; } + if (!is_array($devices)) { + throw new Exception('Firebase notification method "routeNotificationForFirebase" in ' . $notifiable->getTable() . ' should return an array'); + } + $firebase = $notification->toFirebase($notifiable); try {