laravel_notify_fcm 2.1.0 copy "laravel_notify_fcm: ^2.1.0" to clipboard
laravel_notify_fcm: ^2.1.0 copied to clipboard

Laravel Notify for Firebase Cloud Messaging (FCM) - Send push notifications to your Flutter app from Laravel.

Laravel Notify Fcm #

Latest Release Version Latest Stable Version GitHub stars

Laravel Notify Fcm is a package for sending notifications to your Flutter app using Laravel FCM.

Getting started #

Installation #

Add the following to your pubspec.yaml file:

dependencies:
  laravel_notify_fcm: ^2.1.0
copied to clipboard

or with Dart:

dart pub add laravel_notify_fcm
copied to clipboard

Requirements #

Usage #

Using Nylo? Run the following command to scaffold the necessary files for FCM notifications.

dart run laravel_notify_fcm:main install
copied to clipboard

This will create the following files:

  • Provider - FirebaseMessagingProvider (lib/providers/firebase_messaging_provider.dart)
    • This will initialize the package to send notifications to the device.
  • Page - EnableNotificationsPage (lib/pages/enable_notifications_page.dart)
    • This page will request permission to send notifications to the device.
    • You can navigate to it by calling routeTo(EnableNotificationsPage.path);.
  • Event - RegisterForNotificationsEvent (lib/events/register_for_notifications_event.dart)
    • This event will be dispatched to request permission to send notifications to the device.
import 'package:laravel_notify_fcm/laravel_notify_fcm.dart';

copied to clipboard

Adding a device to the database #

First, call init to initialize the package.

Parameters:

  • url - The URL to your Laravel app where the package will send the device token.
  • firebaseMessaging - The FirebaseMessaging instance.
  • debugMode - Whether to enable debug mode. The default is false.
FirebaseMessaging firebaseMessaging = FirebaseMessaging.instance;

await LaravelNotifyFcm.instance.init(
  url: 'https://example.com/api/fcm',
  firebaseMessaging: firebaseMessaging,
);
copied to clipboard

Then, call storeFcmDevice to add the device to the database.


await LaravelNotifyFcm.storeFcmDevice(
  sanctumToken: 'from your Laravel user',
);
copied to clipboard

This method will request permission to send notifications to the device. If the user accepts, the device will be added to the database.

View our docs on Laravel FCM Channel to start sending notifications.

Try the example app to see how it works.

Changelog #

Please see CHANGELOG for more information what has changed recently.

Social #

Licence #

The MIT License (MIT). Please view the License File for more information.

5
likes
160
points
157
downloads

Publisher

unverified uploader

Weekly Downloads

2024.10.03 - 2025.04.17

Laravel Notify for Firebase Cloud Messaging (FCM) - Send push notifications to your Flutter app from Laravel.

Homepage
Repository (GitHub)
View/report issues

Topics

#laravel-fcm #push-notifications #laravel-push-notifications #fcm

Documentation

API reference

Funding

Consider supporting this project:

github.com

License

MIT (license)

Dependencies

dart_console, device_meta, dio, firebase_messaging, flutter, nylo_support, pretty_dio_logger

More

Packages that depend on laravel_notify_fcm