mercredi 11 octobre 2017

How setup laravel-notification-channels/webpush

I have installed http://ift.tt/2xzK0tm in my project but when send notifications there are nothing. It doesnt work This is laravel notifications documentation: http://ift.tt/2vRVNT4

This is my code - I have created a notification:

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');
}}

and I call Notification in my controller:

     $when = Carbon::now();

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

But I Webpush doesnt work. What's wrong?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire