我已经在我的项目中安装了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');
}}我在我的控制器中调用Notification:
$when = Carbon::now();
$request->user()->notify((new AccountApproved)->delay($when));但是我的网络推送不起作用。怎么了?
发布于 2017-10-12 03:16:07
确保您像这样运行queue worker:
php artisan queue:work在命令行中。否则将不会发送排队的通知。
如果它不能帮助您查看错误日志,并验证其中是否有任何错误
发布于 2020-01-24 18:40:26
要使方法通知起作用,您必须添加到通知implements ShouldQueue中
class AccountApproved extends Notification implements ShouldQueue { ... }和ofc use Illuminate\Contracts\Queue\ShouldQueue;在你的课之前
https://stackoverflow.com/questions/46695843
复制相似问题