|
|
|
@ -31,22 +31,25 @@ class _RequestApprovalBottomState extends State<RequestApprovalBottomSheet> {
|
|
|
|
print('listen for approval called..');
|
|
|
|
print('listen for approval called..');
|
|
|
|
if (Platform.isAndroid && !(await isGoogleServicesAvailable())) {
|
|
|
|
if (Platform.isAndroid && !(await isGoogleServicesAvailable())) {
|
|
|
|
h_push.Push.onMessageReceivedStream.listen((h_push.RemoteMessage remoteMessage) {
|
|
|
|
h_push.Push.onMessageReceivedStream.listen((h_push.RemoteMessage remoteMessage) {
|
|
|
|
print("onMessageReceivedStream:${remoteMessage.toMap()}");
|
|
|
|
// ConfirmArrivalNotificationModel notificationModel = ConfirmArrivalNotificationModel.fromJson(remoteMessage);
|
|
|
|
|
|
|
|
// if(notificationModel.requestId!=null&¬ificationModel.accept!=null){
|
|
|
|
|
|
|
|
// if(notificationModel.accept=='True'){
|
|
|
|
|
|
|
|
// Navigator.pop(context, true);
|
|
|
|
|
|
|
|
// }else if(notificationModel.accept=='False'){
|
|
|
|
|
|
|
|
// Navigator.pop(context, false);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
}, onError: (Object error) {
|
|
|
|
}, onError: (Object error) {
|
|
|
|
print("onMessageReceivedStream:${error?.toString()}");
|
|
|
|
print("onMessageReceivedStream:${error.toString()}");
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
FirebaseMessaging.onMessage.listen((RemoteMessage message) {
|
|
|
|
FirebaseMessaging.onMessage.listen((RemoteMessage message) {
|
|
|
|
print('mesage ${message.data}');
|
|
|
|
|
|
|
|
ConfirmArrivalNotificationModel notificationModel = ConfirmArrivalNotificationModel.fromJson(message.data);
|
|
|
|
ConfirmArrivalNotificationModel notificationModel = ConfirmArrivalNotificationModel.fromJson(message.data);
|
|
|
|
print('notification model i got is ${notificationModel.toJson()}');
|
|
|
|
|
|
|
|
if(notificationModel.requestId!=null&¬ificationModel.accept!=null){
|
|
|
|
if(notificationModel.requestId!=null&¬ificationModel.accept!=null){
|
|
|
|
print('accept value is ${notificationModel.accept==false}');
|
|
|
|
if(notificationModel.accept=='True'){
|
|
|
|
if(notificationModel.accept!=null&&!notificationModel.accept!){
|
|
|
|
|
|
|
|
ServiceRequestDetailProvider requestDetailProvider = Provider.of<ServiceRequestDetailProvider>(context,listen: false);
|
|
|
|
|
|
|
|
requestDetailProvider.getWorkOrderById(id: notificationModel.requestId??0);
|
|
|
|
|
|
|
|
Navigator.pop(context, true);
|
|
|
|
|
|
|
|
Navigator.pop(context, true);
|
|
|
|
Navigator.pop(context, true);
|
|
|
|
|
|
|
|
}else if(notificationModel.accept=='False'){
|
|
|
|
|
|
|
|
Navigator.pop(context, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Map<String, dynamic> messageData = message.data;
|
|
|
|
// Map<String, dynamic> messageData = message.data;
|
|
|
|
@ -75,6 +78,8 @@ class _RequestApprovalBottomState extends State<RequestApprovalBottomSheet> {
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
void dispose() {
|
|
|
|
void dispose() {
|
|
|
|
|
|
|
|
print('bottomsheet disposed..');
|
|
|
|
|
|
|
|
|
|
|
|
super.dispose();
|
|
|
|
super.dispose();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -115,10 +120,10 @@ class _RequestApprovalBottomState extends State<RequestApprovalBottomSheet> {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
class ConfirmArrivalNotificationModel {
|
|
|
|
class ConfirmArrivalNotificationModel {
|
|
|
|
final String? transactionType;
|
|
|
|
final String? transactionType;
|
|
|
|
final int? requestId;
|
|
|
|
final String? requestId;
|
|
|
|
final String? notificationType;
|
|
|
|
final String? notificationType;
|
|
|
|
final String? userId;
|
|
|
|
final String? userId;
|
|
|
|
final bool? accept;
|
|
|
|
final String? accept;
|
|
|
|
|
|
|
|
|
|
|
|
ConfirmArrivalNotificationModel({
|
|
|
|
ConfirmArrivalNotificationModel({
|
|
|
|
this.transactionType,
|
|
|
|
this.transactionType,
|
|
|
|
|