live_activities
haroon amjad 3 weeks ago
parent b00a37cabb
commit 83c78cbaf7

@ -1,10 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.application-groups</key>
<array>
<string>group.alhabib.patientApp</string>
</array>
</dict>
</plist>

@ -1,10 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.application-groups</key>
<array>
<string>group.alhabib.patientApp</string>
</array>
</dict>
</plist>

@ -574,7 +574,6 @@ class PushNotificationHandler {
try {
FirebaseMessaging.instance.getInitialMessage().then((RemoteMessage? message) async {
if (message != null) {
if (Platform.isIOS) {
await Future.delayed(Duration(milliseconds: 3000)).then((value) {
@ -638,6 +637,7 @@ class PushNotificationHandler {
// }
}
}
}
newMessage(RemoteMessage remoteMessage) async {
log("Remote Message: ${remoteMessage.data}");

@ -15,8 +15,11 @@ import 'package:get_it/get_it.dart';
import 'package:google_api_availability/google_api_availability.dart';
import 'package:hmg_patient_app_new/core/app_assets.dart';
import 'package:hmg_patient_app_new/core/app_state.dart';
import 'package:hmg_patient_app_new/core/cache_consts.dart';
import 'package:hmg_patient_app_new/core/common_models/patient_queue.dart';
import 'package:hmg_patient_app_new/core/common_models/privilege/ProjectDetailListModel.dart';
import 'package:hmg_patient_app_new/core/dependencies.dart';
import 'package:hmg_patient_app_new/core/utils/live_activty_helper_channel.dart';
import 'package:hmg_patient_app_new/core/utils/size_utils.dart';
import 'package:hmg_patient_app_new/extensions/string_extensions.dart';
import 'package:hmg_patient_app_new/extensions/widget_extensions.dart';
@ -30,6 +33,7 @@ import 'package:hmg_patient_app_new/widgets/dialogs/confirm_dialog.dart';
import 'package:hmg_patient_app_new/widgets/loading_dialog.dart';
import 'package:hmg_patient_app_new/widgets/accessibility/preserve_image_colors.dart';
import 'package:hmg_patient_app_new/widgets/accessibility/preserve_svg_colors.dart';
import 'package:live_activities/live_activities.dart';
import 'package:lottie/lottie.dart';
import 'package:path_provider/path_provider.dart';
import 'package:shared_preferences/shared_preferences.dart';
@ -1172,4 +1176,51 @@ class Utils {
return normalized;
}
static addLiveNotification(dynamic data, {bool isBackgroundMessage = false}) async {
var liveActivity = LiveActivities();
liveActivity.init(appGroupId: "group.alhabib.patientApp");
if (Platform.isIOS) {
LiveActivityHelperChannel.removeData();
}
var queueNoForWhichActivityIdCreated = await Utils.getStringFromPrefs(CacheConst.patientQueueNoForLiveActivity);
var activityId = await Utils.getStringFromPrefs(data.data['queueNo'] ?? "");
var buttonText = Utils.getCardButtonText(int.parse(data.data['callType'] ?? "1"), data.data['roomNo']);
PatientQueue _patientQueue = PatientQueue(
queueNo: data.data['queueNo'] ?? "IME-1",
currentlyServingStatus: (data.data['servingCallType'] ?? 0) == "1" ? LocaleKeys.callForVitalSign.tr() : LocaleKeys.callForDoctor.tr(),
currentlyServingToken: data.data['servingQueueNo'] ?? "IME-3",
nextTicketStatus: buttonText,
callType: int.parse(data.data['callType'] ?? "1"),
currentlyServingCallType: int.parse(data.data['servingCallType'] ?? "1"),
yourTicketHeader: LocaleKeys.yourQueueNumber.tr(),
currentlyServingTitle: LocaleKeys.currentServing.tr());
if ((queueNoForWhichActivityIdCreated ?? "") != (_patientQueue.queueNo ?? "")) {
liveActivity.endActivity(activityId);
activityId = "";
}
if (activityId == "") {
String? id = await liveActivity.createActivity(
DateTime.now().millisecondsSinceEpoch.toString(),
_patientQueue.toMap(),
);
await Utils.saveStringFromPrefs(_patientQueue.queueNo ?? "", id ?? "");
await Utils.saveStringFromPrefs(CacheConst.patientQueueNoForLiveActivity ?? "", _patientQueue.queueNo ?? "");
return;
}
if (Platform.isIOS) {
await liveActivity.createOrUpdateActivity(
activityId,
_patientQueue.toMap(),
);
} else {
await liveActivity.updateActivity(
activityId,
_patientQueue.toMap(),
);
}
}
}

@ -0,0 +1,3 @@
class QueueLiveNotificationModel {
Map<String, dynamic> data = {};
}

@ -12,6 +12,7 @@ import 'package:hmg_patient_app_new/core/utils/size_utils.dart';
import 'package:hmg_patient_app_new/core/utils/utils.dart';
import 'package:hmg_patient_app_new/features/book_appointments/models/resp_models/get_favorite_doctors_list.dart';
import 'package:hmg_patient_app_new/features/my_appointments/models/appointemnet_filters.dart';
import 'package:hmg_patient_app_new/features/my_appointments/models/patient_queue_live_notification_model.dart';
import 'package:hmg_patient_app_new/features/my_appointments/models/reminder_type.dart';
import 'package:hmg_patient_app_new/features/my_appointments/models/resp_models/appointment_parking_QR_response_model.dart';
import 'package:hmg_patient_app_new/features/my_appointments/models/resp_models/appointment_rated_response_model.dart';
@ -1026,6 +1027,19 @@ class MyAppointmentsViewModel extends ChangeNotifier {
// if (patientQueueDetailsList.length > 1) {
patientQueueDetailsList.removeWhere((element) => element.patientID == patientArrivedAppointmentsHistoryList.first.patientID);
// }
QueueLiveNotificationModel queueLiveNotificationModel = QueueLiveNotificationModel();
queueLiveNotificationModel.data = {
"queueNo": currentPatientQueueDetails.queueNo,
"callType": currentPatientQueueDetails.callType.toString(),
"servingQueueNo": patientQueueDetailsList.isEmpty ? null : patientQueueDetailsList.first.queueNo,
"servingCallType": patientQueueDetailsList.isEmpty ? null : patientQueueDetailsList.first.callType.toString(),
"roomNo": patientQueueDetailsList.isEmpty ? "" : patientQueueDetailsList.first.roomNo,
"servingNow": "true"
};
Utils.addLiveNotification(queueLiveNotificationModel, isBackgroundMessage: false);
} else {
patientQueueDetailsList.clear();
isPatientHasQueueAppointment = false;

Loading…
Cancel
Save