Reputation: 1292
I am using ""davibennun/laravel-push-notification": "dev-laravel5" " for sending push notification. What i want is delay in sending notification after hit but dont want to stop the process. Is there any idea how can i do this or is this possible?
Following is the code to send push notification:
$pushNotification = PushNotification::app('appNameAndroid')->to($token);
$pushNotification->adapter->setAdapterParameters(['sslverifypeer' => false]);
$pushNotification->send($message);
Thanks in advance.
Upvotes: 2
Views: 1620
Reputation: 1292
I found how to do this. Following are the steps.
Run the following command
php artisan queue:table
php artisan migrate
Change .env
QUEUE_DRIVER=database
Create a job
php artisan make:job JobName
//In Job file
I have mentioned 2 protected variable in my job file
$message,$deviceToken
In _construct i assigned a value to the above variables.
public function __construct($deviceToken, $message)
{
$this->deviceToken = $deviceToken;
$this->message = $message;
}
In handle method
$pushNotification = PushNotification::app('appNameAndroid')->to($this->deviceToken); $pushNotification->adapter->setAdapterParameters(['sslverifypeer' => false]); $pushNotification->send($this->message);
//In my controller
$job = (new JobName($deviceToken, $message))->delay(10);
$this->dispatch($job);
Upvotes: 3