update
This commit is contained in:
+19
-1
@@ -40,7 +40,7 @@ void main() async {
|
||||
options: DefaultFirebaseOptions.currentPlatform,
|
||||
).then((value) => Get.put(AuthenticationRepository()));
|
||||
|
||||
FirebaseMessaging.onBackgroundMessage((_firebaseMessagingBackgroundHandler));
|
||||
FirebaseMessaging.onBackgroundMessage((message) => _firebaseMessagingBackgroundHandler(message, context)); // Pasa el contexto aquí
|
||||
|
||||
FirebaseMessaging messaging = FirebaseMessaging.instance;
|
||||
|
||||
@@ -76,7 +76,25 @@ void main() async {
|
||||
usePathUrlStrategy();
|
||||
runApp(const MyApp());
|
||||
}
|
||||
Future<void> _firebaseMessagingBackgroundHandler(RemoteMessage message, BuildContext context) async {
|
||||
final Map<String, dynamic> data = message.data;
|
||||
|
||||
if (data['click_action'] == 'FLUTTER_NOTIFICATION_CLICK') {
|
||||
final String screen = data['screen'];
|
||||
|
||||
if (screen == 'solicitud') {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => SolicitudScreen()),
|
||||
);
|
||||
} else if (screen == 'misservicios') {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => MyServicesScreen()),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user