首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何设置laravel-notification channel/webpush

如何设置laravel-notification channel/webpush
EN

Stack Overflow用户
提问于 2017-10-12 03:11:35
回答 2查看 2.4K关注 0票数 2

我已经在我的项目中安装了https://github.com/laravel-notification-channels/webpush,但是当发送通知时什么也没有。它不工作这是laravel通知文档:https://laravel.com/docs/5.5/notifications

这是我的代码-我已经创建了一个通知:

代码语言:javascript
复制
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:

代码语言:javascript
复制
     $when = Carbon::now();

    $request->user()->notify((new AccountApproved)->delay($when));

但是我的网络推送不起作用。怎么了?

EN

回答 2

Stack Overflow用户

发布于 2017-10-12 03:16:07

确保您像这样运行queue worker:

代码语言:javascript
复制
php artisan queue:work

在命令行中。否则将不会发送排队的通知。

如果它不能帮助您查看错误日志,并验证其中是否有任何错误

票数 1
EN

Stack Overflow用户

发布于 2020-01-24 18:40:26

要使方法通知起作用,您必须添加到通知implements ShouldQueue

代码语言:javascript
复制
class AccountApproved extends Notification implements ShouldQueue { ... }

和ofc use Illuminate\Contracts\Queue\ShouldQueue;在你的课之前

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46695843

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档