From d4d4592944247c769724e2cbbb03513362d15fec Mon Sep 17 00:00:00 2001 From: Hamza-Ayed Date: Wed, 7 Feb 2024 21:45:20 +0300 Subject: [PATCH] 2/7/1 --- lib/controller/firebase/firbase_messge.dart | 53 +++++++++------------ 1 file changed, 22 insertions(+), 31 deletions(-) diff --git a/lib/controller/firebase/firbase_messge.dart b/lib/controller/firebase/firbase_messge.dart index e46b033..fb203fc 100644 --- a/lib/controller/firebase/firbase_messge.dart +++ b/lib/controller/firebase/firbase_messge.dart @@ -102,47 +102,45 @@ class FirebaseMessagesController extends GetxController { }); FirebaseMessaging.onMessage.listen((RemoteMessage message) { - if (message.data.isNotEmpty) { + if (message.notification != null && message.data.isNotEmpty) { fireBaseTitles(message); } + // If the app is in the background or terminated, show a system tray message RemoteNotification? notification = message.notification; AndroidNotification? android = notification?.android; // if (notification != null && android != null) { - if (notification != null && android != null) { - // print('onMessageOpenedApp: ${notification.title} ${notification.body}'); - if (message.data.isNotEmpty) { - fireBaseTitles(message); - } + if (message.data.isNotEmpty) { + fireBaseTitles(message); } }); - FirebaseMessaging.onMessageOpenedApp.listen((RemoteMessage message) { - // print( - // 'onMessageOpenedApp: ${message.notification!.title} ${message.notification!.body}'); - RemoteNotification? notification = message.notification; - fireBaseTitles(message); - }); + // FirebaseMessaging.onMessageOpenedApp.listen((RemoteMessage message) { + // // print( + // // 'onMessageOpenedApp: ${message.notification!.title} ${message.notification!.body}'); + // RemoteNotification? notification = message.notification; + // fireBaseTitles(message); + // }); } void fireBaseTitles(RemoteMessage message) { - if (message.notification!.title!.contains('Order')) { + if (message.notification!.title! == 'Order') { var myListString = message.data['DriverList']; - print(myListString); - print('9999999999999myListString999999999999999'); + // print(myListString); + // print('9999999999999myListString999999999999999'); var myList = jsonDecode(myListString) as List; driverToken = myList[14].toString(); update(); - print('driverToken==============$driverToken'); + // print('driverToken==============$driverToken'); Get.to(() => OrderRequestPage(), arguments: { 'myListString': myListString, 'DriverList': myList, 'body': message.notification!.body }); - } else if (message.notification!.title!.contains('Apply Ride')) { + } else if (message.notification!.title! == 'Apply Ride') { var passengerList = message.data['passengerList']; - print(passengerList); - print('9999999999999my Apply Ride 999999999999999'); + // print(passengerList); + // print('9999999999999my Apply Ride 999999999999999'); var myList = jsonDecode(passengerList) as List; driverID = myList[2].toString(); @@ -165,7 +163,7 @@ class FirebaseMessagesController extends GetxController { margin: const EdgeInsets.all(16), padding: const EdgeInsets.all(16), ); - } else if (message.notification!.title!.contains('Promo')) { + } else if (message.notification!.title! == 'Promo') { Get.to(const PromosPassengerPage()); } else if (message.notification!.title == 'Cancel Trip') { Get.defaultDialog( @@ -176,24 +174,17 @@ class FirebaseMessagesController extends GetxController { onPressed: () { Get.offAll(HomeCaptain()); })); - } else if (message.notification!.title! - .contains('DriverIsGoingToPassenger')) { + } else if (message.notification!.title! == 'DriverIsGoingToPassenger') { Get.snackbar('Driver is Going To Passenger', '', backgroundColor: AppColor.greenColor); - } else if (message.notification!.title!.contains('RideIsBegin')) { - // MapPassengerController mapController = Get.put(MapPassengerController()); + } else if (message.notification!.title! == 'RideIsBegin') { Get.snackbar('RideIsBegin', '', backgroundColor: AppColor.greenColor); - // mapController.driverArrivePassenger(); update(); - } else if (message.notification!.title!.contains('Hi ,I will go now')) { - // MapPassengerController mapController = Get.put(MapPassengerController()); + } else if (message.notification!.title! == 'Hi ,I will go now') { Get.snackbar('Hi ,I will go now', '', backgroundColor: AppColor.greenColor); - // mapController.driverArrivePassenger(); update(); - } else if (message.notification!.title! - .contains('Hi ,I Arrive your site')) { - // MapPassengerController mapController = Get.put(MapPassengerController()); + } else if (message.notification!.title! == 'Hi ,I Arrive your site') { Get.defaultDialog( barrierDismissible: false, title: 'Hi ,I Arrive your site'.tr,