Firebase Cloud Notifications for Laravel

The Syntech Firebase Cloud Messaging (FCM) package for Laravel makes it easy to use Laravel's notification system to send Firebase notifications. The use-case for FCM messages includes iOS and Android apps, web applications, flutter, and more:

namespace App\Notifications;
 
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
 
class YourNotification extends Notification
{
    use Queueable;
 
    public function via($notifiable)
    {
        return ['fcm'];
    }
 
    public function toFcm($notifiable)
    {
        return [
            'to' => $notifiable->device_token,
            'notification' => [
                'title'    => 'Notification Title',
                'body'     => 'Notification Body',
                'image'    => '', // Optional image URL
            ],
        ];
    }
}
 
// Usage:
$user->notify(new YourNotification($title, $body));

 

The above example doesn't show that you need device tokens to send FCM notifications, so be sure to read the installation docs for complete setup.

#Learn More

You can learn more about this package, get full installation instructions, and view the source code on GitHub. Also, check out Laravel's Notifications documentation to learn how easy Laravel makes sending notifications.

Syntech FCM GitHub Repository

Laravel Notifications Documentation