How to add PushNotification to Laravel queue?

I have an automatic iOS push notification configured on my Laravel Forge server. However, sometimes not all push notifications are sent. So, I am trying to solve this problem by adding them to the queue. This is the code I have now:

$devices = DB::table('devices')->get();

foreach ($devices as $device)
{
    $push = PushNotification::app('Development')
                ->to($device->device)
                ->send($message);

     $push = PushNotification::app('Distribution')
                ->to($device->device)
                ->send($message);
}

      

Now I tried to do it like this:

$this->dispatch($push = PushNotification::app('Distribution')
                ->to($device->device)
                ->send($message));

      

But that obviously doesn't work. How to do it right? I have to admit that I don't quite understand the syntax of adding to the queue, and it doesn't help, that the documentation is not that clear in this area.

+3


source to share





All Articles