From 32edb2e71ee21fda2a7d99d10ff5e9a88d2c2770 Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Thu, 10 Mar 2022 12:47:23 +0300 Subject: [PATCH 1/3] updates --- lib/config/localized_values.dart | 1 + .../model/er/AmbulanceRequestOrdersModel.dart | 20 +++--- lib/pages/landing/widgets/services_view.dart | 3 +- lib/uitl/translations_delegate_base.dart | 3 +- .../bottom_navigation/bottom_nav_bar.dart | 24 +++---- .../bottom_navigation_item.dart | 68 +++++++++---------- 6 files changed, 57 insertions(+), 62 deletions(-) diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index ffcca5d7..890499a8 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -1758,4 +1758,5 @@ const Map localizedValues = { "ancillaryOrderPaymentSuccess": {"en": "Your payment for selected orders has been made successfully.", "ar": "تم سداد دفعتك للطلبات المحددة بنجاح."}, "connectTitle": {"en": "Connect", "ar": "تواصل"}, "connectSubtitle": {"en": "With us", "ar": "معنا"}, + "covidConsent": {"en": "Covid-19 Test feature allows you to book an appointment for the Covid-19 Lab test within HMG branches, where a swab sample will be collected & processed. Once the result has been processed, we shall notify you via SMS on your registered mobile number & the test result will also be available in the Lab Results section of this app. Please note that this result is only available to you & not publicly available to anyone else. \nPlease accept to confirm & proceed.", "ar": "تتيح لك ميزة اختبار كوفيد19 حجز موعد في احد فروع مجموعة الحبيب الطبية ، حيث سيتم اخذ عينة المسحة ومعالجتها. بمجرد معالجة النتيجة ، سنخطرك عبر رسالة نصية قصيرة على رقم هاتفك المحمول المسجل وستكون نتيجة الاختبار متاحة أيضًا على التطبيق في قسم نتائج المختبر. يرجى ملاحظة أن هذه النتيجة متاحة لك فقط وليست متاحة للجمهور او اي شخص آخر. الرجاء الموافقة للتأكيد والمتابعة."}, }; \ No newline at end of file diff --git a/lib/core/model/er/AmbulanceRequestOrdersModel.dart b/lib/core/model/er/AmbulanceRequestOrdersModel.dart index 72a3fd5f..c08b3574 100644 --- a/lib/core/model/er/AmbulanceRequestOrdersModel.dart +++ b/lib/core/model/er/AmbulanceRequestOrdersModel.dart @@ -228,17 +228,17 @@ class AmbulanceRequestOrdersModel { } class WFOrder { - Null wfButtonsDTO; + dynamic wfButtonsDTO; num iD; num orderId; num previousStep; num nextStep; num serviceId; - Null order; + dynamic order; String created; - Null createdBy; - Null modified; - Null modifiedBy; + dynamic createdBy; + dynamic modified; + dynamic modifiedBy; bool isDeleted; WFOrder( @@ -291,14 +291,14 @@ class WFOrder { class Orderpayment { num iD; num orderId; - Null clientRequestId; + dynamic clientRequestId; num totalAmount; num paymentStatus; - Null order; + dynamic order; String created; - Null createdBy; - Null modified; - Null modifiedBy; + dynamic createdBy; + dynamic modified; + dynamic modifiedBy; bool isDeleted; Orderpayment( diff --git a/lib/pages/landing/widgets/services_view.dart b/lib/pages/landing/widgets/services_view.dart index 323b37de..32c4393a 100644 --- a/lib/pages/landing/widgets/services_view.dart +++ b/lib/pages/landing/widgets/services_view.dart @@ -283,8 +283,7 @@ class ServicesView extends StatelessWidget { builder: (cxt) => CovidConsentDialog( okTitle: TranslationBase.of(context).acceptLbl, title: "User Consent", - message: - "Covid-19 Test feature allows you to book appointment for Covid-19 Lab test within HMG branches where a swab sample will be collected & will be processed. Once the result has been processed you shall be notified via SMS on your registered mobile number & the test result will also be available in the Lab Results section of this app. Please note that this result is only available to you & not publicly available to anyone else. \nPlease accept to confirm & proceed.", + message: TranslationBase.of(context).covidConsent, onTap: () async { Navigator.push(context, FadePage(page: CovidDrivethruLocation())); }, diff --git a/lib/uitl/translations_delegate_base.dart b/lib/uitl/translations_delegate_base.dart index 67f08479..297b669f 100644 --- a/lib/uitl/translations_delegate_base.dart +++ b/lib/uitl/translations_delegate_base.dart @@ -2829,11 +2829,10 @@ class TranslationBase { String get successRegister => localizedValues["successRegister"][locale.languageCode]; String get pharmacyLiveCare => localizedValues["pharmacyLiveCare"][locale.languageCode]; String get ancillaryOrderPaymentSuccess => localizedValues["ancillaryOrderPaymentSuccess"][locale.languageCode]; - String get connectTitle => localizedValues["connectTitle"][locale.languageCode]; String get connectSubtitle => localizedValues["connectSubtitle"][locale.languageCode]; - String get declineLbl => localizedValues["declineLbl"][locale.languageCode]; + String get covidConsent => localizedValues["covidConsent"][locale.languageCode]; } class TranslationBaseDelegate extends LocalizationsDelegate { diff --git a/lib/widgets/bottom_navigation/bottom_nav_bar.dart b/lib/widgets/bottom_navigation/bottom_nav_bar.dart index 9f9c7c0c..6f27fd94 100644 --- a/lib/widgets/bottom_navigation/bottom_nav_bar.dart +++ b/lib/widgets/bottom_navigation/bottom_nav_bar.dart @@ -50,16 +50,16 @@ class _BottomNavBarState extends State { mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ BottomNavigationItem( - icon: DQIcons.my_medical_file, - activeIcon: DQIcons.my_medical_file, + icon: "assets/images/new/bottom_nav/my_file.svg", + activeIcon: "assets/images/new/bottom_nav/my_file.svg", changeIndex: _changeIndex, index: widget.index, currentIndex: 1, name: TranslationBase.of(context).medicalFile, ), BottomNavigationItem( - icon: DQIcons.family, - activeIcon: DQIcons.family, + icon: "assets/images/new/bottom_nav/family_files.svg", + activeIcon: "assets/images/new/bottom_nav/family_files.svg", changeIndex: _changeIndex, index: widget.index, currentIndex: 3, @@ -69,8 +69,8 @@ class _BottomNavBarState extends State { if (widget.index == 0) (widget.showHomeIcon) ? BottomNavigationItem( - icon: Icons.home_outlined, - activeIcon: Icons.home_outlined, + icon: "assets/images/new/bottom_nav/home.svg", + activeIcon: "assets/images/new/bottom_nav/home.svg", changeIndex: _changeIndex, index: widget.index, currentIndex: 2, @@ -79,8 +79,8 @@ class _BottomNavBarState extends State { : Expanded(child: SizedBox()), if (widget.index != 0 && projectViewModel.havePrivilege(34)) BottomNavigationItem( - icon: Icons.home_outlined, - activeIcon: Icons.home_outlined, + icon: "assets/images/new/bottom_nav/home.svg", + activeIcon: "assets/images/new/bottom_nav/home.svg", changeIndex: _changeIndex, index: widget.index, currentIndex: 0, @@ -96,8 +96,8 @@ class _BottomNavBarState extends State { // ), if (/*widget.index == 0 && */ projectViewModel.havePrivilege(34)) BottomNavigationItem( - icon: Icons.calendar_today_sharp, - activeIcon: Icons.calendar_today_sharp, + icon: "assets/images/new/bottom_nav/todo.svg", + activeIcon: "assets/images/new/bottom_nav/todo.svg", changeIndex: _changeIndex, index: widget.index, currentIndex: 4, @@ -105,8 +105,8 @@ class _BottomNavBarState extends State { ), if (projectViewModel.havePrivilege(77)) BottomNavigationItem( - icon: DQIcons.roboticon, - activeIcon: DQIcons.roboticon, + icon: "assets/images/new/bottom_nav/help.svg", + activeIcon: "assets/images/new/bottom_nav/help.svg", changeIndex: _changeIndex, index: widget.index, currentIndex: 5, diff --git a/lib/widgets/bottom_navigation/bottom_navigation_item.dart b/lib/widgets/bottom_navigation/bottom_navigation_item.dart index f01f70af..b729aa91 100644 --- a/lib/widgets/bottom_navigation/bottom_navigation_item.dart +++ b/lib/widgets/bottom_navigation/bottom_navigation_item.dart @@ -6,13 +6,14 @@ import 'package:diplomaticquarterapp/models/Appointments/toDoCountProviderModel. import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_svg/flutter_svg.dart'; import 'package:provider/provider.dart'; import '../../Constants.dart'; class BottomNavigationItem extends StatelessWidget { - final IconData icon; - final IconData activeIcon; + final String icon; + final String activeIcon; final ValueChanged changeIndex; final int index; final int currentIndex; @@ -46,14 +47,12 @@ class BottomNavigationItem extends StatelessWidget { SizedBox( height: 15, ), - Container( - child: Icon(currentIndex == index ? activeIcon : icon, - color: currentIndex == index - ? secondaryColor - : isDisabled - ? Colors.grey[300] - : Colors.grey, - size: 22.0), + icon == "assets/images/new/bottom_nav/help.svg" ? Container( + child: SvgPicture.asset(icon, height: 20, width: 20, fit: BoxFit.cover), + ) : Container( + child: SvgPicture.asset(icon, height: 20, width: 20, fit: BoxFit.cover, color: currentIndex == index + ? Color(0xff333c45) + : Color(0xff989898)), ), SizedBox( height: 2, @@ -62,7 +61,7 @@ class BottomNavigationItem extends StatelessWidget { name, textAlign: TextAlign.center, color: currentIndex == index - ? secondaryColor + ? Color(0xff333c45) : isDisabled ? Colors.grey[300] : Colors.grey, @@ -77,21 +76,6 @@ class BottomNavigationItem extends StatelessWidget { ? Stack( alignment: AlignmentDirectional.center, children: [ - Positioned( - right: 18.0, - bottom: 28.0, - child: Badge( - toAnimate: false, - position: BadgePosition.topEnd(), - shape: BadgeShape.circle, - badgeColor: secondaryColor.withOpacity(1.0), - borderRadius: BorderRadius.circular(8), - badgeContent: Container( - padding: EdgeInsets.all(2.0), - child: Text(model.count.toString(), style: TextStyle(color: Colors.white, fontSize: 14.0)), - ), - ), - ), Column( mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.center, @@ -100,7 +84,10 @@ class BottomNavigationItem extends StatelessWidget { height: 15, ), Container( - child: Icon(currentIndex == index ? activeIcon : icon, color: currentIndex == index ? secondaryColor : Theme.of(context).dividerColor, size: 22.0), + child: SvgPicture.asset(icon, height: 20, width: 20, fit: BoxFit.cover, color: currentIndex == index + ? Color(0xff333c45) + : Color(0xff989898)), + // Icon(currentIndex == index ? activeIcon : icon, color: currentIndex == index ? secondaryColor : Theme.of(context).dividerColor, size: 22.0), ), SizedBox( height: 2, @@ -108,7 +95,7 @@ class BottomNavigationItem extends StatelessWidget { Texts( name, textAlign: TextAlign.center, - color: currentIndex == index ? Theme.of(context).primaryColor : Colors.grey, + color: currentIndex == index ? Color(0xff333c45) : Colors.grey, fontSize: 11, ), SizedBox( @@ -116,6 +103,21 @@ class BottomNavigationItem extends StatelessWidget { ), ], ), + Positioned( + right: 18.0, + bottom: 28.0, + child: Badge( + toAnimate: false, + position: BadgePosition.topEnd(), + shape: BadgeShape.circle, + badgeColor: secondaryColor.withOpacity(1.0), + borderRadius: BorderRadius.circular(8), + badgeContent: Container( + padding: EdgeInsets.all(2.0), + child: Text(model.count.toString(), style: TextStyle(color: Colors.white, fontSize: 14.0)), + ), + ), + ), ], ) : Column( @@ -126,13 +128,7 @@ class BottomNavigationItem extends StatelessWidget { height: 15, ), Container( - child: Icon(currentIndex == index ? activeIcon : icon, - color: currentIndex == index - ? secondaryColor - : isDisabled - ? Colors.grey[300] - : Theme.of(context).dividerColor, - size: 22.0), + child: SvgPicture.asset(icon, height: 20, width: 20, fit: BoxFit.cover), ), SizedBox( height: 2, @@ -141,7 +137,7 @@ class BottomNavigationItem extends StatelessWidget { name, textAlign: TextAlign.center, color: currentIndex == index - ? secondaryColor + ? Color(0xff333c45) : isDisabled ? Colors.grey[300] : Colors.grey, From 7d7864a1ebf407ebc46b5a845e4b762c6c7669ea Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Thu, 10 Mar 2022 13:29:44 +0300 Subject: [PATCH 2/3] livecare changes --- lib/pages/livecare/incoming_call.dart | 9 ++++----- lib/pages/livecare/video-call-web-page.dart | 13 ++++++++++--- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/lib/pages/livecare/incoming_call.dart b/lib/pages/livecare/incoming_call.dart index 2dfbe3e4..ec832e96 100644 --- a/lib/pages/livecare/incoming_call.dart +++ b/lib/pages/livecare/incoming_call.dart @@ -3,7 +3,6 @@ import 'dart:ui'; import 'package:camera/camera.dart'; import 'package:diplomaticquarterapp/models/LiveCare/IncomingCallData.dart'; import 'package:diplomaticquarterapp/models/LiveCare/room_model.dart'; -import 'package:diplomaticquarterapp/pages/conference/web_rtc/call_home_page.dart'; import 'package:diplomaticquarterapp/pages/conference/web_rtc/call_home_page_.dart'; import 'package:diplomaticquarterapp/pages/conference/widgets/platform_exception_alert_dialog.dart'; import 'package:diplomaticquarterapp/pages/landing/landing_page.dart'; @@ -34,7 +33,6 @@ class _IncomingCallState extends State with SingleTickerProviderSt bool isCameraReady = false; Signaling signaling = Signaling()..init(); - @override void initState() { _animationController = AnimationController(vsync: this, duration: Duration(milliseconds: 500)); @@ -231,16 +229,17 @@ class _IncomingCallState extends State with SingleTickerProviderSt Future _submit() async { try { + // backToHome(); final roomModel = RoomModel(name: widget.incomingCallData.name, token: widget.incomingCallData.sessionId, identity: widget.incomingCallData.identity); await _controller.dispose(); await Navigator.of(context).pushReplacement( MaterialPageRoute( fullscreenDialog: true, builder: (BuildContext context) { - if(openCallInWeb) + if (openCallInWeb) return VideoCallWebPage(receiverId: widget.incomingCallData.receiverID, callerId: widget.incomingCallData.callerID); - - return CallHomePage(receiverId: widget.incomingCallData.receiverID, callerId: widget.incomingCallData.callerID); + else + return CallHomePage(receiverId: widget.incomingCallData.receiverID, callerId: widget.incomingCallData.callerID); }, ), ); diff --git a/lib/pages/livecare/video-call-web-page.dart b/lib/pages/livecare/video-call-web-page.dart index 0587343c..2aa802b0 100644 --- a/lib/pages/livecare/video-call-web-page.dart +++ b/lib/pages/livecare/video-call-web-page.dart @@ -13,7 +13,7 @@ class VideoCallWebPage extends StatelessWidget{ final String receiverId; final String callerId; VideoCallWebPage({@required this.receiverId, @required this.callerId}){ - request = URLRequest(url: Uri.parse("https://vcallapi.hmg.com/index.html?username=$receiverId")); + request = URLRequest(url: Uri.parse("https://vcallapi.hmg.com/Mobileindex.html?username=$receiverId&doctorid=$callerId")); } InAppWebViewGroupOptions options = InAppWebViewGroupOptions( @@ -64,7 +64,7 @@ class VideoCallWebPage extends StatelessWidget{ onLoadStart: onLoadStart, onLoadError: onError, onConsoleMessage: onConsoleMessage, - shouldOverrideUrlLoading: shouldRedirect , + // shouldOverrideUrlLoading: shouldRedirect , ), ), ], @@ -93,11 +93,18 @@ class VideoCallWebPage extends StatelessWidget{ } onLoadStart(InAppWebViewController controller, Uri url) { + print(url); + if(url.toString().toLowerCase().contains("endcallpage")){ + Navigator.pop(webViewKey.currentContext); + } } Future shouldRedirect(InAppWebViewController controller, NavigationAction navigationAction) async { var uri = navigationAction.request.url; - if(uri.queryParameters['exit'] == "yes"){ + // if(uri.queryParameters['exit'] == "yes"){ + // Navigator.pop(webViewKey.currentContext); + // } + if(uri.toString().toLowerCase().contains("endcallpage")){ Navigator.pop(webViewKey.currentContext); } From 8c96de866bd9330364d75ab01dcedaad426853a3 Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Sun, 13 Mar 2022 09:46:41 +0300 Subject: [PATCH 3/3] updates --- lib/pages/livecare/incoming_call.dart | 8 +- lib/pages/livecare/video-call-web-page.dart | 17 ++- .../appointment_services/GetDoctorsList.dart | 1 + lib/uitl/push-notification-handler.dart | 139 ++++++++---------- 4 files changed, 80 insertions(+), 85 deletions(-) diff --git a/lib/pages/livecare/incoming_call.dart b/lib/pages/livecare/incoming_call.dart index ec832e96..d81aaec5 100644 --- a/lib/pages/livecare/incoming_call.dart +++ b/lib/pages/livecare/incoming_call.dart @@ -234,12 +234,12 @@ class _IncomingCallState extends State with SingleTickerProviderSt await _controller.dispose(); await Navigator.of(context).pushReplacement( MaterialPageRoute( - fullscreenDialog: true, + // fullscreenDialog: true, builder: (BuildContext context) { - if (openCallInWeb) + // if (openCallInWeb) return VideoCallWebPage(receiverId: widget.incomingCallData.receiverID, callerId: widget.incomingCallData.callerID); - else - return CallHomePage(receiverId: widget.incomingCallData.receiverID, callerId: widget.incomingCallData.callerID); + // else + // return CallHomePage(receiverId: widget.incomingCallData.receiverID, callerId: widget.incomingCallData.callerID); }, ), ); diff --git a/lib/pages/livecare/video-call-web-page.dart b/lib/pages/livecare/video-call-web-page.dart index 2aa802b0..9cc20020 100644 --- a/lib/pages/livecare/video-call-web-page.dart +++ b/lib/pages/livecare/video-call-web-page.dart @@ -1,3 +1,4 @@ +import 'package:diplomaticquarterapp/pages/landing/landing_page.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; @@ -6,7 +7,7 @@ import 'package:flutter_inappwebview/flutter_inappwebview.dart'; class VideoCallWebPage extends StatelessWidget{ final GlobalKey webViewKey = GlobalKey(); - InAppWebViewController webViewController; + // InAppWebViewController webViewController; InAppWebViewController controller; URLRequest request; @@ -51,7 +52,7 @@ class VideoCallWebPage extends StatelessWidget{ ), extendBodyBehindAppBar: true, extendBody: false, - backgroundColor: Colors.white, + // backgroundColor: Colors.white, body: Column( children: [ SizedBox(height: MediaQuery.of(context).viewPadding.top), @@ -82,7 +83,10 @@ class VideoCallWebPage extends StatelessWidget{ ); } - onWebViewCreated(InAppWebViewController controller) => this.controller = controller; + onWebViewCreated(InAppWebViewController controller) { + this.controller = controller; + LandingPage.isOpenCallPage = true; + } onConsoleMessage(controller, ConsoleMessage consoleMessage){ print(consoleMessage); @@ -95,7 +99,12 @@ class VideoCallWebPage extends StatelessWidget{ onLoadStart(InAppWebViewController controller, Uri url) { print(url); if(url.toString().toLowerCase().contains("endcallpage")){ - Navigator.pop(webViewKey.currentContext); + LandingPage.isOpenCallPage = false; + if(LandingPage.isOpenCallPage == true) { + print("END CALL!!!"); + // controller.goBack(); + Navigator.pop(webViewKey.currentContext); + } } } diff --git a/lib/services/appointment_services/GetDoctorsList.dart b/lib/services/appointment_services/GetDoctorsList.dart index e9613628..383af15b 100644 --- a/lib/services/appointment_services/GetDoctorsList.dart +++ b/lib/services/appointment_services/GetDoctorsList.dart @@ -698,6 +698,7 @@ class DoctorsListService extends BaseService { "ProjectID": projectID, "ServiceID": serviceID, "AcceptedBy": docID, + "IsFlutter": true, "DeviceToken": deviceToken, "Latitude": lat, "Longitude": long, diff --git a/lib/uitl/push-notification-handler.dart b/lib/uitl/push-notification-handler.dart index da34b296..b9fba256 100644 --- a/lib/uitl/push-notification-handler.dart +++ b/lib/uitl/push-notification-handler.dart @@ -1,134 +1,124 @@ - import 'dart:convert'; import 'dart:io'; + import 'package:diplomaticquarterapp/config/config.dart'; import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; import 'package:diplomaticquarterapp/models/LiveCare/IncomingCallData.dart'; import 'package:diplomaticquarterapp/pages/landing/landing_page.dart'; import 'package:diplomaticquarterapp/pages/livecare/incoming_call.dart'; import 'package:diplomaticquarterapp/uitl/app-permissions.dart'; -import 'package:flutter/cupertino.dart'; -import 'package:flutter/material.dart'; -import 'package:huawei_push/huawei_push.dart' as h_push; import 'package:firebase_messaging/firebase_messaging.dart'; import 'package:firebase_messaging/firebase_messaging.dart' as fir; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; import 'package:flutter_hms_gms_availability/flutter_hms_gms_availability.dart'; -import 'package:shared_preferences/shared_preferences.dart'; +import 'package:huawei_push/huawei_push.dart' as h_push; import 'app_shared_preferences.dart'; import 'navigation_service.dart'; - // |--> Push Notification Background -Future backgroundMessageHandler(dynamic message) async{ - +Future backgroundMessageHandler(dynamic message) async { fir.RemoteMessage message_; - if(message is h_push.RemoteMessage){ // if huawei remote message convert it to Firebase Remote Message + if (message is h_push.RemoteMessage) { + // if huawei remote message convert it to Firebase Remote Message message_ = toFirebaseRemoteMessage(message); } - if (message_.data != null && message_.data['is_call'] == 'true') { - _incomingCall(message_.data); + if (message.data != null && message.data['is_call'] == 'true') { + _incomingCall(message.data); return; } - h_push.Push.localNotification({ - h_push.HMSLocalNotificationAttr.TITLE: 'Background Message', - h_push.HMSLocalNotificationAttr.MESSAGE: "By: BackgroundMessageHandler" - }); - + h_push.Push.localNotification({h_push.HMSLocalNotificationAttr.TITLE: 'Background Message', h_push.HMSLocalNotificationAttr.MESSAGE: "By: BackgroundMessageHandler"}); } // Push Notification Background <--| - - -RemoteMessage toFirebaseRemoteMessage(h_push.RemoteMessage message){ +RemoteMessage toFirebaseRemoteMessage(h_push.RemoteMessage message) { final payload_data = jsonDecode(message.data); final fire_message = RemoteMessage( - from: message.from, - collapseKey: message.collapseKey, - data: payload_data['data'], - messageId: message.messageId, - sentTime: DateTime.fromMillisecondsSinceEpoch(message.sentTime*1000), - ttl: message.ttl, - category: null, - messageType: message.type, - notification: RemoteNotification( - title: message.notification.title, - titleLocArgs: (message.notification.titleLocalizationArgs ?? []).map((e) => e.toString()).toList(), - titleLocKey: message.notification.titleLocalizationKey, - body: message.notification.body, - bodyLocArgs: (message.notification.bodyLocalizationArgs ?? []).map((e) => e.toString()).toList(), - bodyLocKey: message.notification.bodyLocalizationKey, - android: AndroidNotification( - channelId: message.notification.channelId, - clickAction: message.notification.clickAction, - color: message.notification.color, - count: null, - imageUrl: message.notification.imageUrl.path, - link: message.notification.link.path, - smallIcon: message.notification.icon, - sound: message.notification.sound, - ticker: message.notification.ticker, - tag: message.notification.tag, - ), - ) - ); + from: message.from, + collapseKey: message.collapseKey, + data: payload_data['data'], + messageId: message.messageId, + sentTime: DateTime.fromMillisecondsSinceEpoch(message.sentTime * 1000), + ttl: message.ttl, + category: null, + messageType: message.type, + notification: RemoteNotification( + title: message.notification.title, + titleLocArgs: (message.notification.titleLocalizationArgs ?? []).map((e) => e.toString()).toList(), + titleLocKey: message.notification.titleLocalizationKey, + body: message.notification.body, + bodyLocArgs: (message.notification.bodyLocalizationArgs ?? []).map((e) => e.toString()).toList(), + bodyLocKey: message.notification.bodyLocalizationKey, + android: AndroidNotification( + channelId: message.notification.channelId, + clickAction: message.notification.clickAction, + color: message.notification.color, + count: null, + imageUrl: message.notification.imageUrl.path, + link: message.notification.link.path, + smallIcon: message.notification.icon, + sound: message.notification.sound, + ticker: message.notification.ticker, + tag: message.notification.tag, + ), + )); return fire_message; } -_incomingCall(Map data) async{ +_incomingCall(Map data) async { + print("_incomingCall CALLED!!!!!! $data"); + // print(ModalRoute.of(currentContext).settings.name); LandingPage.incomingCallData = IncomingCallData.fromJson(data); - if(LandingPage.isOpenCallPage == false){ + if (LandingPage.isOpenCallPage == false) { LandingPage.isOpenCallPage = true; final permited = await AppPermission.askVideoCallPermission(currentContext); - if(permited) - await NavigationService.navigateToPage(IncomingCall(incomingCallData: LandingPage.incomingCallData)); - LandingPage.isOpenCallPage = false; + if (permited) await NavigationService.navigateToPage(IncomingCall(incomingCallData: LandingPage.incomingCallData)); + // LandingPage.isOpenCallPage = false; } await Future.delayed(Duration(milliseconds: 500)); await AppSharedPreferences().remove('call_data'); } -class PushNotificationHandler{ +class PushNotificationHandler { final BuildContext context; static PushNotificationHandler _instance; - PushNotificationHandler(this.context){ + PushNotificationHandler(this.context) { PushNotificationHandler._instance = this; } static PushNotificationHandler getInstance() => _instance; - init() async{ + init() async { if (Platform.isIOS) { final permission = await FirebaseMessaging.instance.requestPermission(); - if(permission.authorizationStatus == AuthorizationStatus.denied) - return; + if (permission.authorizationStatus == AuthorizationStatus.denied) return; } - if(Platform.isAndroid && (await FlutterHmsGmsAvailability.isHmsAvailable)) { // 'Android HMS' (Handle Huawei Push_Kit Streams) + if (Platform.isAndroid && (await FlutterHmsGmsAvailability.isHmsAvailable)) { + // 'Android HMS' (Handle Huawei Push_Kit Streams) h_push.Push.enableLogger(); final result = await h_push.Push.setAutoInitEnabled(true); - h_push.Push.onNotificationOpenedApp.listen((message){ + h_push.Push.onNotificationOpenedApp.listen((message) { newMessage(toFirebaseRemoteMessage(message)); }, onError: (e) => print(e.toString())); - h_push.Push.onMessageReceivedStream.listen((message){ + h_push.Push.onMessageReceivedStream.listen((message) { newMessage(toFirebaseRemoteMessage(message)); }, onError: (e) => print(e.toString())); - - h_push.Push.getTokenStream.listen((token){ + h_push.Push.getTokenStream.listen((token) { onToken(token); }, onError: (e) => print(e.toString())); await h_push.Push.getToken(''); - h_push.Push.registerBackgroundMessageHandler(backgroundMessageHandler); - - }else{ // 'Android GMS or iOS' (Handle Firebase Messaging Streams) + } else { + // 'Android GMS or iOS' (Handle Firebase Messaging Streams) FirebaseMessaging.onMessage.listen((RemoteMessage message) async { newMessage(message); @@ -145,19 +135,15 @@ class PushNotificationHandler{ FirebaseMessaging.onBackgroundMessage(backgroundMessageHandler); final fcmToken = await FirebaseMessaging.instance.getToken(); - if(fcmToken != null) - onToken(fcmToken); + if (fcmToken != null) onToken(fcmToken); } } - - newMessage(RemoteMessage remoteMessage){ - if(remoteMessage.data['is_call'] == 'true' || remoteMessage.data['is_call'] == true) - _incomingCall(remoteMessage.data); - + newMessage(RemoteMessage remoteMessage) { + if (remoteMessage.data['is_call'] == 'true' || remoteMessage.data['is_call'] == true) _incomingCall(remoteMessage.data); } - onToken(String token) async{ + onToken(String token) async { print("Push Notification Token: " + token); AppSharedPreferences().setString(PUSH_TOKEN, token); DEVICE_TOKEN = token; @@ -165,11 +151,10 @@ class PushNotificationHandler{ onResume() async { var call_data = await AppSharedPreferences().getObject('call_data'); - if(call_data != null){ + if (call_data != null) { _incomingCall(call_data); } } - } /* todo verify all functionality */ @@ -275,4 +260,4 @@ class PushNotificationHandler{ // print("Is Call Not Found iOS"); // } // }, -// ); \ No newline at end of file +// );