2017-10-11 70 views
0

我已經在我的項目中安裝了https://github.com/laravel-notification-channels/webpush ,但發送通知時什麼也沒有。它不工作 這是laravel通知文件:https://laravel.com/docs/5.5/notifications安裝laravel-notification-channels/webpush

這是我的代碼 - 我創建了一個通知:

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不起作用。怎麼了?

回答

1

請確保您正在運行的隊列工作是這樣的:

php artisan queue:work 

在命令行。否則排隊的通知將不會被髮送。

如果它不幫助看看你的錯誤日誌,並驗證是否有任何錯誤

+0

這很奇怪,PHP工匠隊列:工作無法正常工作。經過幾分鐘的等待,控制檯仍然凍結。我會在Google上找到解決方案,然後我再回來 –

+1

也許它有效,但發送通知失敗,並且您在「laravel.log」文件中收到錯誤 –