Skip to content

Commit 60f2409

Browse files
committed
Add events dispatcher
1 parent a23003e commit 60f2409

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/FirebaseChannel.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
use paragraph1\phpFCM\Client;
77
use paragraph1\phpFCM\Message;
88
use paragraph1\phpFCM\Recipient\Device;
9+
use \Illuminate\Events\Dispatcher;
10+
use Illuminate\Notifications\Events\NotificationFailed;
911
use Illuminate\Notifications\Notification;
1012

1113
class FirebaseChannel
@@ -17,14 +19,23 @@ class FirebaseChannel
1719
*/
1820
protected $client;
1921

22+
/**
23+
* Events dispatcher.
24+
*
25+
* @var \Illuminate\Events\Dispatcher
26+
*/
27+
protected $events;
28+
2029
/**
2130
* Push Service constructor.
2231
*
2332
* @param \paragraph1\phpFCM\Client $client
33+
* @param \Illuminate\Events\Dispatcher $events
2434
*/
25-
public function __construct(Client $client)
35+
public function __construct(Client $client, Dispatcher $events)
2636
{
2737
$this->client = $client;
38+
$this->events = $events;
2839
}
2940

3041
/**
@@ -54,6 +65,9 @@ public function send($notifiable, Notification $notification)
5465
$this->client->send($message);
5566
}
5667
} catch (Exception $e) {
68+
$this->events->fire(
69+
new NotificationFailed($notifiable, $notification, $this)
70+
);
5771
}
5872
}
5973
}

0 commit comments

Comments
 (0)