我已经在我的项目中安装了https://github.com/laravel-notification-channels/webpush 但是发送通知时什么都没有。它不起作用这是 laravel 通知文档:https ://laravel.com/docs/5.5/notifications
这是我的代码 - 我创建了一个通知:
class AccountApproved extends Notification {
use Queueable;
public function __construct()
{
//
}
public function via($notifiable)
{
return [WebPushChannel::class];
}
public function toArray($notifiable)
{
return [
'title' => 'Hello from Laravel!',
'body' => 'Thank you for using our application.',
'action_url' => 'https://laravel.com',
'created' => Carbon::now()->toIso8601String()
];
}
public function toWebPush($notifiable, $notification)
{
return WebPushMessage::create()
->title('Hello from Laravel!')
->icon('/notification-icon.png')
->body('Thank you for using our application.')
->action('View app', 'view_app');
}}
我在我的控制器中调用通知:
$when = Carbon::now();
$request->user()->notify((new AccountApproved)->delay($when));
但我 Webpush 不起作用。怎么了?