Skip to content

Commit cabb8ea

Browse files
committed
v3.x
1 parent 7c31fe8 commit cabb8ea

30 files changed

+1356
-1728
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,6 @@ build/
7272
!**/ios/**/default.mode2v3
7373
!**/ios/**/default.pbxuser
7474
!**/ios/**/default.perspectivev3
75+
76+
CLAUDE.md
77+
.claude

CHANGELOG.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,27 @@
1+
## [3.0.0] - 2026-02-06
2+
3+
### Added
4+
- `LaravelNotifyFcmNotInitializedException` custom exception for clearer error handling when the package is not initialized.
5+
- New test suite with unit, integration, API service, and interceptor tests.
6+
- Proper type annotations on `apiServiceFcm` return type and interceptors getter.
7+
8+
### Changed
9+
- **BREAKING**: `init()` no longer requires a `firebaseMessaging` parameter. The package no longer manages `FirebaseMessaging` internally -- consumers must manage Firebase directly.
10+
- **BREAKING**: `storeFcmDevice()` now requires `fcmToken` as a positional parameter and returns `Future<bool?>` instead of `Future<NotificationSettings?>`.
11+
- **BREAKING**: `enableFcmDevice()` and `disableFcmDevice()` now require `fcmToken` as a positional parameter and `sanctumToken` as a named parameter.
12+
- **BREAKING**: Sanctum token is now passed per-call instead of being stored as instance state. Removed `getSanctumToken()` and `setSanctumToken()` methods.
13+
- Authentication header (`Authorization: Bearer`) is now set at the API request level instead of via the interceptor.
14+
- Interceptor now gracefully handles uninitialized state instead of throwing.
15+
- Upgraded `nylo_support` to ^7.0.0, `device_meta` to ^3.0.0, `dio` to ^5.9.0.
16+
17+
### Removed
18+
- **BREAKING**: `firebase_messaging` direct dependency. Consumers must add `firebase_messaging` to their own `pubspec.yaml` and pass the FCM token to this package.
19+
- **BREAKING**: `getFirebaseMessaging()` method.
20+
- **BREAKING**: `getFcmToken()` static method.
21+
- **BREAKING**: `getSanctumToken()` and `setSanctumToken()` methods.
22+
- CLI scaffolding system (`bin/main.dart`, `lib/cli_dialog/`, `lib/stubs/`, `lib/slate_laravel_notify_fcm.dart`, `lib/models/`).
23+
- `pretty_dio_logger` dependency.
24+
125
## [2.1.5] - 2025-12-17
226

327
* Add extra check to `getFcmToken` method to ensure token is not null

README.md

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -33,24 +33,8 @@ dart pub add laravel_notify_fcm
3333

3434
### Usage
3535

36-
Using Nylo? Run the following command to scaffold the necessary files for FCM notifications.
37-
38-
``` bash
39-
dart run laravel_notify_fcm:main install
40-
```
41-
42-
This will create the following files:
43-
- Provider - `FirebaseMessagingProvider` (lib/providers/firebase_messaging_provider.dart)
44-
- This will initialize the package to send notifications to the device.
45-
- Page - `EnableNotificationsPage` (lib/pages/enable_notifications_page.dart)
46-
- This page will request permission to send notifications to the device.
47-
- You can navigate to it by calling `routeTo(EnableNotificationsPage.path);`.
48-
- Event - `RegisterForNotificationsEvent` (lib/events/register_for_notifications_event.dart)
49-
- This event will be dispatched to request permission to send notifications to the device.
50-
5136
``` dart
5237
import 'package:laravel_notify_fcm/laravel_notify_fcm.dart';
53-
5438
```
5539

5640
### Adding a device to the database
@@ -59,28 +43,30 @@ First, call `init` to initialize the package.
5943

6044
Parameters:
6145
- `url` - The URL to your Laravel app where the package will send the device token.
62-
- `firebaseMessaging` - The FirebaseMessaging instance.
6346
- `debugMode` - Whether to enable debug mode. The default is `false`.
6447

6548
```dart
66-
FirebaseMessaging firebaseMessaging = FirebaseMessaging.instance;
67-
6849
await LaravelNotifyFcm.instance.init(
6950
url: 'https://example.com/api/fcm',
70-
firebaseMessaging: firebaseMessaging,
7151
);
7252
```
7353

74-
Then, call `storeFcmDevice` to add the device to the database.
54+
Then, call `storeFcmDevice` to register the device with your Laravel backend.
55+
56+
Parameters:
57+
- `fcmToken` - The FCM token from `FirebaseMessaging.instance.getToken()`.
58+
- `sanctumToken` - A valid Laravel Sanctum token for the authenticated user.
7559

7660
``` dart
61+
String? fcmToken = await FirebaseMessaging.instance.getToken();
7762
7863
await LaravelNotifyFcm.storeFcmDevice(
64+
fcmToken,
7965
sanctumToken: 'from your Laravel user',
8066
);
8167
```
8268

83-
This method will request permission to send notifications to the device. If the user accepts, the device will be added to the database.
69+
This will send the device token and metadata to your Laravel backend via a PUT `/device` request.
8470

8571
View our [docs](https://github.com/nylo-core/laravel-fcm-channel) on Laravel FCM Channel to start sending notifications.
8672

bin/main.dart

Lines changed: 0 additions & 78 deletions
This file was deleted.

example/lib/main.dart

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
1-
import 'package:firebase_messaging/firebase_messaging.dart';
21
import 'package:flutter/material.dart';
32
import 'package:laravel_notify_fcm/laravel_notify_fcm.dart';
43

54
void main() async {
65
// Firebase.initializeApp();
76
WidgetsFlutterBinding.ensureInitialized();
8-
FirebaseMessaging firebaseMessaging = FirebaseMessaging.instance;
97

108
LaravelNotifyFcm.instance.init(
11-
firebaseMessaging: firebaseMessaging,
129
url: "https://example.com/api/fcm",
1310
debugMode: true,
1411
);
@@ -52,9 +49,6 @@ class _MyHomePageState extends State<MyHomePage> {
5249
child: Text("Enable notifications"),
5350
onTap: () async {
5451
// get your sanctum token from your Laravel app
55-
56-
await LaravelNotifyFcm.storeFcmDevice(
57-
sanctumToken: 'sanctumToken');
5852
},
5953
),
6054
),

0 commit comments

Comments
 (0)