berkayk / laravel-onesignal

OneSignal Push Notifications for Laravel
506 stars 176 forks source link

Notifications are not being sent (?) #133

Closed dlogvin closed 4 years ago

dlogvin commented 4 years ago

I setup a command, and apparently, no notifications are being triggered.

how it looks:

<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;

use App\Task;
use OneSignal;
use Carbon\Carbon;

class NotifyUsers extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'users:notify';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Command description';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        $tasks = Task::where('duedate', '>=', now())->with('user')->get();
        foreach($tasks as $task){
            $diffInDays = $task->duedate->diff(Carbon::now())->days;
                OneSignal::sendNotificationToUser(
                    "Your deadline for $task->title is in $diffInDays days",
                    $task->user->deviceId,
                    $url = null,
                    $data = null,
                    $buttons = null,
                    $schedule = null
                );
        }
    }
}

I made some dd() and the device ID is indeed appearing, but nothing is really getting sent...

this is intended to send push notifications to ios

dlogvin commented 4 years ago

Woops, apparently, it works! sorry.