Added native os notifications
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Notifications;
|
||||
|
||||
use App\Models\Notification as NotificationModel;
|
||||
use Illuminate\Notifications\Notification;
|
||||
use NotificationChannels\WebPush\WebPushChannel;
|
||||
use NotificationChannels\WebPush\WebPushMessage;
|
||||
|
||||
class PushNotification extends Notification
|
||||
{
|
||||
public function __construct(
|
||||
protected NotificationModel $notification
|
||||
) {}
|
||||
|
||||
public function via($notifiable): array
|
||||
{
|
||||
return [WebPushChannel::class];
|
||||
}
|
||||
|
||||
public function toWebPush($notifiable, $notification): WebPushMessage
|
||||
{
|
||||
return (new WebPushMessage)
|
||||
->title($this->notification->title)
|
||||
->body($this->notification->body)
|
||||
->icon( '/img/app_icons/icon-192.png')
|
||||
->data([
|
||||
'url' => $this->notification->url,
|
||||
'notification_id' => $this->notification->id,
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user