bLOQUE p1 BACKEND Y SEGURIDAD, AUTENTICACION CON SUPABASE. jwt. RBAC CRUD
This commit is contained in:
36
recolecta_app/lib/app/bootstrap.dart
Normal file
36
recolecta_app/lib/app/bootstrap.dart
Normal file
@@ -0,0 +1,36 @@
|
||||
import 'package:firebase_core/firebase_core.dart';
|
||||
import 'package:firebase_messaging/firebase_messaging.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
import '../firebase_options.dart';
|
||||
|
||||
final bootstrapProvider = FutureProvider<void>((ref) async {
|
||||
await dotenv.load(fileName: 'assets/.env');
|
||||
await _initializeFirebase();
|
||||
FirebaseMessaging.onBackgroundMessage(_firebaseMessagingBackgroundHandler);
|
||||
});
|
||||
|
||||
Future<void> _initializeFirebase() async {
|
||||
try {
|
||||
await Firebase.initializeApp(
|
||||
options: DefaultFirebaseOptions.currentPlatform,
|
||||
);
|
||||
} on UnsupportedError {
|
||||
await Firebase.initializeApp();
|
||||
}
|
||||
}
|
||||
|
||||
@pragma('vm:entry-point')
|
||||
Future<void> _firebaseMessagingBackgroundHandler(RemoteMessage message) async {
|
||||
try {
|
||||
await _initializeFirebase();
|
||||
} catch (_) {
|
||||
// Ignore reinitialization errors in the background isolate.
|
||||
}
|
||||
|
||||
debugPrint(
|
||||
'FCM background message received: ${message.messageId} | data: ${message.data}',
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user