From b1ac1c153031746548b053fb078b765d63a68955 Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Wed, 29 Apr 2026 11:34:29 +0300 Subject: [PATCH] redirection notification implemented --- lib/config/config.dart | 2 +- .../get_notifications_response_model.dart | 20 +++++++++++++++++- lib/core/service/client/base_app_client.dart | 2 +- .../medical/prescriptions_service.dart | 2 +- .../notification_details_page.dart | 21 +++++++++++++++++++ lib/uitl/push-notification-handler.dart | 5 +++++ 6 files changed, 48 insertions(+), 4 deletions(-) diff --git a/lib/config/config.dart b/lib/config/config.dart index 74bf8305..81ab834f 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -358,7 +358,7 @@ var CAN_PAY_FOR_FOR_WALKIN_APPOINTMENT = 'Services/Doctors.svc/REST/CanPayForWal var CHANNEL = 3; var GENERAL_ID = 'Cs2020@2016\$2958'; var IP_ADDRESS = '10.20.10.20'; -var VERSION_ID = 20.3; +var VERSION_ID = 20.4; var SETUP_ID = '91877'; var LANGUAGE = 2; // var PATIENT_OUT_SA = 0; diff --git a/lib/core/model/notifications/get_notifications_response_model.dart b/lib/core/model/notifications/get_notifications_response_model.dart index 60b9c764..c4916161 100644 --- a/lib/core/model/notifications/get_notifications_response_model.dart +++ b/lib/core/model/notifications/get_notifications_response_model.dart @@ -20,6 +20,11 @@ class GetNotificationsResponseModel { String? isReadOn; int? channelID; int? projectID; + String? isExternalRedirect; + String? externalRedirectURLAndroid; + String? externalRedirectURLIos; + String? redirectButtonTextEn; + String? redirectButtonTextAr; GetNotificationsResponseModel( {this.id, @@ -42,7 +47,10 @@ class GetNotificationsResponseModel { this.isRead, this.isReadOn, this.channelID, - this.projectID}); + this.projectID, + this.isExternalRedirect, + this.externalRedirectURLAndroid, + this.externalRedirectURLIos, this.redirectButtonTextEn, this.redirectButtonTextAr}); GetNotificationsResponseModel.fromJson(Map json) { id = json['Id']; @@ -66,6 +74,11 @@ class GetNotificationsResponseModel { isReadOn = json['IsReadOn']; channelID = json['ChannelID']; projectID = json['ProjectID']; + isExternalRedirect = json['isExternalRedirect']; + externalRedirectURLAndroid = json['externalRedirectURLAndroid']; + externalRedirectURLIos = json['externalRedirectURLIos']; + redirectButtonTextEn = json['redirectButtonTextEn']; + redirectButtonTextAr = json['redirectButtonTextAr']; } Map toJson() { @@ -91,6 +104,11 @@ class GetNotificationsResponseModel { data['IsReadOn'] = this.isReadOn; data['ChannelID'] = this.channelID; data['ProjectID'] = this.projectID; + data['isExternalRedirect'] = this.isExternalRedirect; + data['externalRedirectURLAndroid'] = this.externalRedirectURLAndroid; + data['externalRedirectURLIos'] = this.externalRedirectURLIos; + data['redirectButtonTextEn'] = this.redirectButtonTextEn; + data['redirectButtonTextAr'] = this.redirectButtonTextAr; return data; } } diff --git a/lib/core/service/client/base_app_client.dart b/lib/core/service/client/base_app_client.dart index acea685a..9c0f86f5 100644 --- a/lib/core/service/client/base_app_client.dart +++ b/lib/core/service/client/base_app_client.dart @@ -189,7 +189,7 @@ class BaseAppClient { // body['IdentificationNo'] = 1023854217; // body['MobileNo'] = "531940021"; //0560717232 - // body['PatientID'] = 4774402; //4609100 + // body['PatientID'] = 1018977; //4609100 //2904826 // body['TokenID'] = "@dm!n"; // Patient ID: 3027574 diff --git a/lib/core/service/medical/prescriptions_service.dart b/lib/core/service/medical/prescriptions_service.dart index f24b36cb..303cb9b4 100644 --- a/lib/core/service/medical/prescriptions_service.dart +++ b/lib/core/service/medical/prescriptions_service.dart @@ -260,7 +260,7 @@ class PrescriptionsService extends BaseService { body['Id'] = presOrderID; body['StatusId'] = 6; body['ClickButton'] = 14; - await baseAppClient.post(UPDATE_PRESCRIPTION_ORDER_RC, onSuccess: (dynamic response, int statusCode) {}, onFailure: (String error, int statusCode) { + await baseAppClient.post(UPDATE_PRESCRIPTION_ORDER_RC, isRCService: true, onSuccess: (dynamic response, int statusCode) {}, onFailure: (String error, int statusCode) { hasError = true; super.error = error; }, body: body); diff --git a/lib/pages/DrawerPages/notifications/notification_details_page.dart b/lib/pages/DrawerPages/notifications/notification_details_page.dart index c0f99079..78115746 100644 --- a/lib/pages/DrawerPages/notifications/notification_details_page.dart +++ b/lib/pages/DrawerPages/notifications/notification_details_page.dart @@ -1,9 +1,16 @@ +import 'dart:io'; + import 'package:hmg_patient_app/core/model/notifications/get_notifications_response_model.dart'; +import 'package:hmg_patient_app/core/viewModels/project_view_model.dart'; +import 'package:hmg_patient_app/theme/colors.dart'; import 'package:hmg_patient_app/uitl/date_uitl.dart'; import 'package:hmg_patient_app/uitl/translations_delegate_base.dart'; +import 'package:hmg_patient_app/widgets/buttons/defaultButton.dart'; import 'package:hmg_patient_app/widgets/others/app_scaffold_widget.dart'; import 'package:hmg_patient_app/widgets/progress_indicator/app_circular_progress_Indeicator.dart'; import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; +import 'package:url_launcher/url_launcher.dart'; import 'package:youtube_player_flutter/youtube_player_flutter.dart'; class NotificationsDetailsPage extends StatefulWidget { @@ -60,6 +67,7 @@ class _NotificationsDetailsPageState extends State { @override Widget build(BuildContext context) { + ProjectViewModel projectViewModel = Provider.of(context); return AppScaffold( isShowAppBar: true, showNewAppBar: true, @@ -115,6 +123,19 @@ class _NotificationsDetailsPageState extends State { }, fit: BoxFit.fill), ), SizedBox(height: 18), + (widget.notification.isExternalRedirect.toString() == "true") + ? DefaultButton( + projectViewModel.isArabic ? widget.notification.redirectButtonTextAr! : widget.notification.redirectButtonTextEn!, + () { + if (Platform.isIOS) { + launchUrl(Uri.parse(widget.notification.externalRedirectURLIos.toString())); + } else { + launchUrl(Uri.parse(widget.notification.externalRedirectURLAndroid.toString())); + } + }, + color: CustomColors.accentColor, + ) + : SizedBox(), // Text( // widget.notification.message!.trim(), // style: TextStyle( diff --git a/lib/uitl/push-notification-handler.dart b/lib/uitl/push-notification-handler.dart index cd9f0150..de97c817 100644 --- a/lib/uitl/push-notification-handler.dart +++ b/lib/uitl/push-notification-handler.dart @@ -408,6 +408,11 @@ class PushNotificationHandler { notification.messageTypeData = remoteMessage.data['picture']; notification.message = remoteMessage.data['message']; notification.notificationType = remoteMessage.data["NotificationType"].toString(); + notification.isExternalRedirect = remoteMessage.data["isExternalRedirect"].toString(); + notification.externalRedirectURLAndroid = remoteMessage.data["externalRedirectURLAndroid"].toString(); + notification.externalRedirectURLIos = remoteMessage.data["externalRedirectURLIos"].toString(); + notification.redirectButtonTextEn = remoteMessage.data["redirectButtonTextEn"].toString(); + notification.redirectButtonTextAr = remoteMessage.data["redirectButtonTextAr"].toString(); if (remoteMessage.data["NotificationType"] == "2") { notification.videoURL = remoteMessage.data["VideoUrl"]; }