Laravel queues & push

2.1k Views Asked by At

I am using the library: https://github.com/davibennun/laravel-push-notification

I am trying to convert this (100% working) example:

Queue::push(function() {
    $push = PushNotification::app('SomeApp')
                    ->to('some_recipient')
                    ->send('Hello World, im a push message');
});

To something like this:

$push = PushNotification::app('SomeApp')
                ->to('some_recipient')
                ->queue('Hello World, im a push message'); // notice ->send is switched out to ->queue (like the Mail::queue method)

I have tried this:

In the App.php (facade for PushNotification) - see: https://github.com/davibennun/laravel-push-notification/tree/master/src/Davibennun/LaravelPushNotification.

public function queue($message, $options = array()) {

    Queue::push(function($job) use($message, $options) {
        $this->send($message, $options);

        $job->delete();
    });

    return $this;
}

Now, my method does not work if my queue provider is Iron - it, however, works perfectly if my queue is sync which is not so effective.

The first provided example works, but is not as pretty as the way I wish to accomplish the same thing.

0

There are 0 best solutions below