sameed_editz's avatar

notification not sending to devices using in laravel using fcm by laravel-notification-channels/fcm

im using laravel-notification-channels/fcm package to send notifications to all my devices

i have a table and model named DeviceToken.php that stores all the devicetokens/fcm_tokens of devices

DeviceToken.php Model

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Notifications\Notifiable;

class DeviceToken extends Model
{
    use Notifiable;

    protected $fillable = ['fcm_token'];

    public static function getAllTokens(): array
    {
        return self::pluck('fcm_token')->toArray();
    }
}

now i have notification table and i want that whenever a new notification is created then that notification is sent to all devices not to any specific users

so i did this

SendNotification.php Notification Class

and thats my observer below which is called whenever a new notification record is created in db

NotificationObserver.php

in logs i see this

[2025-01-30 15:41:25] local.INFO: Notification sent to 3 devices.  
[2025-01-30 15:42:14] local.INFO: Notification sent to 3 devices.  

no error seems here but not a single device recieve notification

please help me im stuck with it

1 like
0 replies

Please or to participate in this conversation.