Skip to content

Commit 6857f97

Browse files
committed
v2.1.0
1 parent 9e8d862 commit 6857f97

21 files changed

+1317
-72
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## [2.1.0] - 2025-02-05
2+
3+
* Add the ability to scaffold Notifications in your Nylo app
4+
* Run `dart run laravel_notify_fcm:main install` to scaffold the necessary files for FCM notifications
5+
* pubspec.yaml update
6+
* Update Readme
7+
18
## [2.0.0] - 2025-01-12
29

310
* Small Refactor

README.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Add the following to your `pubspec.yaml` file:
1616

1717
``` yaml
1818
dependencies:
19-
laravel_notify_fcm: ^2.0.0
19+
laravel_notify_fcm: ^2.1.0
2020
```
2121
2222
or with Dart:
@@ -33,6 +33,21 @@ 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+
3651
``` dart
3752
import 'package:laravel_notify_fcm/laravel_notify_fcm.dart';
3853
@@ -51,7 +66,7 @@ Parameters:
5166
FirebaseMessaging firebaseMessaging = FirebaseMessaging.instance;
5267
5368
await LaravelNotifyFcm.instance.init(
54-
url: 'https://example.com/api/fcm/devices',
69+
url: 'https://example.com/api/fcm',
5570
firebaseMessaging: firebaseMessaging,
5671
);
5772
```

bin/main.dart

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
import 'dart:io';
2+
3+
import 'package:laravel_notify_fcm/cli_dialog/cli_dialog.dart';
4+
import 'package:laravel_notify_fcm/models/ny_laravel_slate_config.dart';
5+
import 'package:laravel_notify_fcm/slate_laravel_notify_fcm.dart';
6+
import 'package:nylo_support/metro/metro_console.dart';
7+
import 'package:nylo_support/metro/metro_service.dart';
8+
import 'package:nylo_support/metro/models/ny_template.dart';
9+
10+
void main(List<String> arguments) async {
11+
if (arguments.length != 1) {
12+
MetroConsole.writeInRed("Invalid arguments");
13+
MetroConsole.writeInRed("Usage: dart run laravel_notify_fcm:main install");
14+
exit(1);
15+
}
16+
17+
String command = arguments[0];
18+
if (command != 'install') {
19+
MetroConsole.writeInRed("Invalid command");
20+
MetroConsole.writeInRed("Usage: dart run laravel_notify_fcm:main install");
21+
exit(1);
22+
}
23+
24+
final dialogLaravelUrl = CliDialog(questions: [
25+
['What is your Laravel Url?', 'laravel_url']
26+
]);
27+
28+
String laravelUrl = dialogLaravelUrl.ask()['laravel_url'];
29+
// remove trailing slash if exists
30+
if (laravelUrl.endsWith('/')) {
31+
laravelUrl = laravelUrl.substring(0, laravelUrl.length - 1);
32+
}
33+
34+
await MetroService.addPackage("firebase_core");
35+
await MetroService.addPackage("firebase_messaging");
36+
await MetroService.addPackage("laravel_notify_fcm");
37+
38+
NyLaravelSlateConfig nyLaravelSlateConfig = NyLaravelSlateConfig(
39+
url: laravelUrl,
40+
);
41+
42+
List<NyTemplate> templates = laravelNotifyFcmSlateRun(nyLaravelSlateConfig);
43+
await MetroService.createSlate(templates, hasForceFlag: true);
44+
45+
MetroConsole.writeInGreen(
46+
'Go to your Laravel project\n\nRun: composer require nylo/laravel-fcm-channel\n\nThen run: php artisan laravelfcm:install');
47+
MetroConsole.writeInGreen(
48+
'Make sure you have Laravel Sanctum installed\n Run: php artisan install:api\n\nYour User model must use the HasApiTokens trait');
49+
50+
// usage instructions
51+
String usageInstructions = '''
52+
Use the following code to register for notifications:
53+
event<RegisterForNotificationsEvent>();
54+
55+
Make sure to call this code after the user has logged in.
56+
57+
You can also use the enable notifications page:
58+
routeTo(EnableNotificationsPage.path);
59+
60+
This will prompt the user to enable notifications.
61+
''';
62+
63+
String firebaseInfo = "\nSetup Firebase";
64+
firebaseInfo +=
65+
"\n- Create a Firebase project: https://console.firebase.google.com";
66+
firebaseInfo +=
67+
"\n- Download flutterfire: https://firebase.google.com/docs/flutter/setup";
68+
firebaseInfo += "\n- Run `flutterfire configure`";
69+
firebaseInfo += "\n- For IOS, you'll need to do the following steps";
70+
firebaseInfo +=
71+
"\n - Project settings > Cloud Messaging > iOS app configuration";
72+
firebaseInfo +=
73+
"\n - Add your APNs Authentication Key from your Apple Developer account";
74+
75+
MetroConsole.writeInGreen("\n\n$usageInstructions$firebaseInfo");
76+
77+
exit(0);
78+
}

example/pubspec.lock

Lines changed: 35 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@ packages:
55
dependency: transitive
66
description:
77
name: _flutterfire_internals
8-
sha256: "27899c95f9e7ec06c8310e6e0eac967707714b9f1450c4a58fa00ca011a4a8ae"
8+
sha256: e4f2a7ef31b0ab2c89d2bde35ef3e6e6aff1dce5e66069c6540b0e9cfe33ee6b
99
url: "https://pub.dev"
1010
source: hosted
11-
version: "1.3.49"
11+
version: "1.3.50"
1212
animate_do:
1313
dependency: transitive
1414
description:
1515
name: animate_do
16-
sha256: "7a3162729f0ea042f9dd84da217c5bde5472ad9cef644079929d4304a5dc4ca0"
16+
sha256: f517dec9c98c1ea2c6e82e172ac138f6b102394a8e843b74bd18f665858e8c1c
1717
url: "https://pub.dev"
1818
source: hosted
19-
version: "3.3.4"
19+
version: "3.3.7"
2020
app_badge_plus:
2121
dependency: transitive
2222
description:
@@ -105,14 +105,22 @@ packages:
105105
url: "https://pub.dev"
106106
source: hosted
107107
version: "3.0.3"
108+
dart_console:
109+
dependency: transitive
110+
description:
111+
name: dart_console
112+
sha256: "30776f697c440fdf5615a5b4fa318fd03c0788a2aeb30625a5972e83592b40c5"
113+
url: "https://pub.dev"
114+
source: hosted
115+
version: "4.1.1"
108116
date_field:
109117
dependency: transitive
110118
description:
111119
name: date_field
112-
sha256: "921246e5e8fb8e22c82e234de48dde27f9c739071a38dac666258909fd2f7b14"
120+
sha256: "5714b1ac0ba1c860877b3040601a6fd20cb846042c9ae6d8216ffede422d43d1"
113121
url: "https://pub.dev"
114122
source: hosted
115-
version: "6.0.0"
123+
version: "6.0.3+1"
116124
dbus:
117125
dependency: transitive
118126
description:
@@ -141,18 +149,18 @@ packages:
141149
dependency: transitive
142150
description:
143151
name: device_meta
144-
sha256: "74c40791731b499432d2c35986645949e34a0ccdfd3f4daa376486d356898816"
152+
sha256: "9af36e12370e0bb647f30946d1fd256fae47663638ce5113c5b6345d0d356da5"
145153
url: "https://pub.dev"
146154
source: hosted
147-
version: "2.1.1"
155+
version: "2.1.2"
148156
dio:
149157
dependency: transitive
150158
description:
151159
name: dio
152-
sha256: "5598aa796bbf4699afd5c67c0f5f6e2ed542afc956884b9cd58c306966efc260"
160+
sha256: "253a18bbd4851fecba42f7343a1df3a9a4c1d31a2c1b37e221086b4fa8c8dbc9"
153161
url: "https://pub.dev"
154162
source: hosted
155-
version: "5.7.0"
163+
version: "5.8.0+1"
156164
dio_web_adapter:
157165
dependency: transitive
158166
description:
@@ -173,10 +181,10 @@ packages:
173181
dependency: transitive
174182
description:
175183
name: error_stack
176-
sha256: "9b4b685fbee04cc4a72f0791663caac5838585d32f83e15ab64f9c8957ec506b"
184+
sha256: ffa61cf73940d61d501c97d14421a2ad7d3a2809fa38bb5c81ef3acee6f131a0
177185
url: "https://pub.dev"
178186
source: hosted
179-
version: "1.10.1"
187+
version: "1.10.2"
180188
fake_async:
181189
dependency: transitive
182190
description:
@@ -205,10 +213,10 @@ packages:
205213
dependency: transitive
206214
description:
207215
name: firebase_core
208-
sha256: "0307c1fde82e2b8b97e0be2dab93612aff9a72f31ebe9bfac66ed8b37ef7c568"
216+
sha256: d851c1ca98fd5a4c07c747f8c65dacc2edd84a4d9ac055d32a5f0342529069f5
209217
url: "https://pub.dev"
210218
source: hosted
211-
version: "3.10.0"
219+
version: "3.10.1"
212220
firebase_core_platform_interface:
213221
dependency: transitive
214222
description:
@@ -229,26 +237,26 @@ packages:
229237
dependency: transitive
230238
description:
231239
name: firebase_messaging
232-
sha256: "48a8a59197c1c5174060ba9aa1e0036e9b5a0d28a0cc22d19c1fcabc67fafe3c"
240+
sha256: e20ea2a0ecf9b0971575ab3ab42a6e285a94e50092c555b090c1a588a81b4d54
233241
url: "https://pub.dev"
234242
source: hosted
235-
version: "15.2.0"
243+
version: "15.2.1"
236244
firebase_messaging_platform_interface:
237245
dependency: transitive
238246
description:
239247
name: firebase_messaging_platform_interface
240-
sha256: "9770a8e91f54296829dcaa61ce9b7c2f9ae9abbf99976dd3103a60470d5264dd"
248+
sha256: c57a92b5ae1857ef4fe4ae2e73452b44d32e984e15ab8b53415ea1bb514bdabd
241249
url: "https://pub.dev"
242250
source: hosted
243-
version: "4.6.0"
251+
version: "4.6.1"
244252
firebase_messaging_web:
245253
dependency: transitive
246254
description:
247255
name: firebase_messaging_web
248-
sha256: "329ca4ef45ec616abe6f1d5e58feed0934a50840a65aa327052354ad3c64ed77"
256+
sha256: "83694a990d8525d6b01039240b97757298369622ca0253ad0ebcfed221bf8ee0"
249257
url: "https://pub.dev"
250258
source: hosted
251-
version: "3.10.0"
259+
version: "3.10.1"
252260
fixnum:
253261
dependency: transitive
254262
description:
@@ -380,10 +388,10 @@ packages:
380388
dependency: transitive
381389
description:
382390
name: flutter_timezone
383-
sha256: "6e6a0a9d0dfc049b209e01e1dee3efd5ff2ddf2375e9de86589761b244eb5a5f"
391+
sha256: bc286cecb0366d88e6c4644e3962ebd1ce1d233abc658eb1e0cd803389f84b64
384392
url: "https://pub.dev"
385393
source: hosted
386-
version: "4.0.0"
394+
version: "4.1.0"
387395
flutter_web_plugins:
388396
dependency: transitive
389397
description: flutter
@@ -393,10 +401,10 @@ packages:
393401
dependency: transitive
394402
description:
395403
name: get_time_ago
396-
sha256: "0f50a87080a720f5491266a3f7c79109f95943decd10b66c84b5aef802f1d959"
404+
sha256: "1bf7bebe32e070e2a5aa9a84ee401c88895de337e9e168e70416ec3373771243"
397405
url: "https://pub.dev"
398406
source: hosted
399-
version: "2.1.1"
407+
version: "2.2.0"
400408
http:
401409
dependency: transitive
402410
description:
@@ -435,7 +443,7 @@ packages:
435443
path: ".."
436444
relative: true
437445
source: path
438-
version: "2.0.0"
446+
version: "2.1.0"
439447
leak_tracker:
440448
dependency: transitive
441449
description:
@@ -496,10 +504,10 @@ packages:
496504
dependency: transitive
497505
description:
498506
name: nylo_support
499-
sha256: "28707d9a8b3a71f820ce367e708139e3d3ac32e83e7af5c7f2d519533f78003f"
507+
sha256: fcec6528167d8ca4d0c8b3f989b1202f4ea5fdc8487826ba1517adb95574a94c
500508
url: "https://pub.dev"
501509
source: hosted
502-
version: "6.15.0"
510+
version: "6.19.1"
503511
path:
504512
dependency: transitive
505513
description:

lib/cli_dialog/cli_dialog.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export 'src/dialog.dart';
2+
export 'src/services.dart';
3+
export 'src/xterm.dart' show XTerm;

0 commit comments

Comments
 (0)