feat: implement FCM push notifications via firebase_messaging

- Add firebase_core + firebase_messaging to pubspec.yaml
- Initialize Firebase in main.dart before runApp
- NotificationBloc: request permission, get FCM token, register with
  backend (PATCH /users/me/fcm-token), show local notification on
  foreground messages, refresh token on rotation
- app_view.dart: call initializePushNotifications() on authenticated state

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Lizandro Guarnizo
2026-06-18 12:43:41 -05:00
co-authored by Claude Sonnet 4.6
parent 5e92d2b908
commit 79f350e85f
4 changed files with 79 additions and 4 deletions
+7 -1
View File
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:prosappco/blocs/notification_bloc/notification_bloc.dart';
import 'package:prosappco/screens/authentication/welcome_screen.dart';
import 'package:prosappco/screens/home/home_screen.dart';
import 'package:prosappco/screens/splash/splash_screen.dart';
@@ -36,7 +37,12 @@ class MyAppView extends StatelessWidget {
secondaryContainer: Colors.red,
),
),
home: BlocBuilder<AuthenticationBloc, AuthenticationState>(
home: BlocConsumer<AuthenticationBloc, AuthenticationState>(
listener: (context, state) {
if (state.status == AuthenticationStatus.authenticated) {
context.read<NotificationBloc>().initializePushNotifications();
}
},
builder: (context, state) {
return getScreen(state);
},