|
|
|
|
@ -68,7 +68,7 @@ Future<dynamic> backgroundMessageHandler(dynamic message) async {
|
|
|
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
|
|
|
DartPluginRegistrant.ensureInitialized();
|
|
|
|
|
await Future.delayed(Duration(seconds: 2));
|
|
|
|
|
addLiveNotification(message, isBackgroundMessage: true);
|
|
|
|
|
Utils.addLiveNotification(message, isBackgroundMessage: true);
|
|
|
|
|
} catch (e, stackTrace) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -115,54 +115,54 @@ Future<dynamic> backgroundMessageHandler(dynamic message) async {
|
|
|
|
|
// print("the activity is is created or updated");
|
|
|
|
|
//
|
|
|
|
|
// }
|
|
|
|
|
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(),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 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(),
|
|
|
|
|
// );
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
callPage(String sessionID, String token) async {}
|
|
|
|
|
|
|
|
|
|
@ -669,7 +669,7 @@ class PushNotificationHandler {
|
|
|
|
|
// );
|
|
|
|
|
// print("the activity is $activity");
|
|
|
|
|
|
|
|
|
|
addLiveNotification(remoteMessage, isBackgroundMessage: false);
|
|
|
|
|
Utils.addLiveNotification(remoteMessage, isBackgroundMessage: false);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
|