【问题标题】:Push notification for android and ios in laravel with queue带有队列的laravel中的android和ios推送通知
【发布时间】:2017-04-12 08:20:10
【问题描述】:

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

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

【问题讨论】:

    标签: php laravel push-notification laravel-5.3 laravel-queue


    【解决方案1】:

    运行以下命令后

    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

    【讨论】:

    • 这对我很有帮助,非常感谢。我创建了一个带有参数 user_id、消息、标题的 SendPushNotification 类
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-20
    • 2014-02-06
    • 2014-05-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多