Skip to content

Commit 73cebff

Browse files
authored
Return the response after sending the message
Laravel's notification sender (`Illuminate\Notifications\NotificationSender`) dispatches an event (`Illuminate\Notifications\Events\NotificationSent`) after the message has been sent. This event contains the response returned from the specific notification channel. When no response is returned, this event's response attribute contains `null`. However, this information could be useful - for logging purposes, for pairing the notification messages with the users etc.
1 parent dc1ae9b commit 73cebff

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/OneSignalChannel.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public function __construct(OneSignalClient $oneSignal)
2323
* @param mixed $notifiable
2424
* @param \Illuminate\Notifications\Notification $notification
2525
*
26+
* @return \Psr\Http\Message\ResponseInterface
2627
* @throws \NotificationChannels\OneSignal\Exceptions\CouldNotSendNotification
2728
*/
2829
public function send($notifiable, Notification $notification)
@@ -45,5 +46,7 @@ public function send($notifiable, Notification $notification)
4546
if ($response->getStatusCode() !== 200) {
4647
throw CouldNotSendNotification::serviceRespondedWithAnError($response);
4748
}
49+
50+
return $response;
4851
}
4952
}

0 commit comments

Comments
 (0)