gpt4 book ai didi

php - 使用队列在 laravel 中为 android 和 ios 推送通知

转载 作者:行者123 更新时间:2023-12-02 04:35:46 27 4
gpt4 key购买 nike

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

我已经创建了迁移队列表并创建了作业php artisan make:job SendPushNotification 命令。

最佳答案

运行以下命令后

php artisan make:job SendPushNotification

从你的 Controller

$user = User::all();
$other_data = array('消息' => '这是消息');
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 队列:工作

关于php - 使用队列在 laravel 中为 android 和 ios 推送通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43364056/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com