使用队列推送 android 和 ios 中 laravel 的通知

Push notification for android and ios in laravel with queue

我正在使用 davibennun/laravel-push-notification 包向设备发送通知。但是我想向多个用户发送通知,因为我想使用 laravel queue。但是我是 laravel 的新手,所以不知道如何使用带有通知的队列。

我已经创建了迁移队列 table 并通过 php artisan make:job SendPushNotification 命令。

在运行 之后

php artisan make:job SendPushNotification

来自您的控制器

$user = User::all(); $other_data = array('message' => 'This is message'); SendPushNotification::dispatch($user, $other_data);

在app\Jobs\SendPushNotification.php

protected $contacts;
protected $sms_data;

public function __construct($users, $other_data)
{
    //

  $this->users = $users;
  $this->other_data = $other_data;
}


public function handle()
{

    $users = $this->users;
    $other_data = $this->other_data;


    foreach($users as $key => $value){

      // You code
   }

运行 遵循命令

php artisan queue:work