https://github.com/nylo-core/laravel-notify-fcm
Laravel Notify for Firebase Cloud Messaging (FCM) - Send push notifications to your Flutter app from Laravel.
https://github.com/nylo-core/laravel-notify-fcm
firebase-cloud-messaging flutter flutter-firebase-cloud-messaging flutter-notification laravel
Last synced: 5 months ago
JSON representation
Laravel Notify for Firebase Cloud Messaging (FCM) - Send push notifications to your Flutter app from Laravel.
- Host: GitHub
- URL: https://github.com/nylo-core/laravel-notify-fcm
- Owner: nylo-core
- License: mit
- Created: 2024-06-07T08:56:51.000Z (about 2 years ago)
- Default Branch: 2.x
- Last Pushed: 2025-12-13T11:07:30.000Z (7 months ago)
- Last Synced: 2025-12-15T01:23:11.990Z (7 months ago)
- Topics: firebase-cloud-messaging, flutter, flutter-firebase-cloud-messaging, flutter-notification, laravel
- Language: Dart
- Homepage: https://nylo.dev
- Size: 156 KB
- Stars: 6
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Laravel Notify Fcm
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:
``` yaml
dependencies:
laravel_notify_fcm: ^2.1.5
```
or with Dart:
``` bash
dart pub add laravel_notify_fcm
```
### Requirements
- [Laravel](https://laravel.com/)
- [Laravel Sanctum](https://laravel.com/docs/11.x/sanctum)
- [laravel-fcm-channel](https://github.com/nylo-core/laravel-fcm-channel)
### Usage
Using Nylo? Run the following command to scaffold the necessary files for FCM notifications.
``` bash
dart run laravel_notify_fcm:main install
```
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.
``` dart
import 'package:laravel_notify_fcm/laravel_notify_fcm.dart';
```
### 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`.
```dart
FirebaseMessaging firebaseMessaging = FirebaseMessaging.instance;
await LaravelNotifyFcm.instance.init(
url: 'https://example.com/api/fcm',
firebaseMessaging: firebaseMessaging,
);
```
Then, call `storeFcmDevice` to add the device to the database.
``` dart
await LaravelNotifyFcm.storeFcmDevice(
sanctumToken: 'from your Laravel user',
);
```
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](https://github.com/nylo-core/laravel-fcm-channel) on Laravel FCM Channel to start sending notifications.
Try the [example](/example) app to see how it works.
## Changelog
Please see [CHANGELOG](https://github.com/nylo-core/laravel-notify-fcm/blob/master/CHANGELOG.md) for more information what has changed recently.
## Social
* [Twitter](https://twitter.com/nylo_dev)
## Licence
The MIT License (MIT). Please view the [License](https://github.com/nylo-core/laravel-notify-fcm/blob/main/LICENSE) File for more information.