From b184f2adf929800cd020c1e4d414b436c4d42359 Mon Sep 17 00:00:00 2001 From: "J. A. Messias" Date: Thu, 12 Sep 2024 13:31:50 -0300 Subject: [PATCH] WIP --- android/app/src/main/AndroidManifest.xml | 14 +- .../notifications/notification_service.dart | 134 +++++------------- lib/main.dart | 4 +- 3 files changed, 51 insertions(+), 101 deletions(-) diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 78402ac8..36196b33 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -62,6 +62,14 @@ + + + + + + + + @@ -71,9 +79,9 @@ - + diff --git a/lib/backend/notifications/notification_service.dart b/lib/backend/notifications/notification_service.dart index 5b10eb25..c5501118 100644 --- a/lib/backend/notifications/notification_service.dart +++ b/lib/backend/notifications/notification_service.dart @@ -36,104 +36,44 @@ Future onMessageReceived( FlutterFlowIconButton( icon: const Icon(Icons.done), onPressed: () async { - showDialog( - context: context, - builder: (context) { - return AlertDialog( - title: Text( - FFLocalizations.of(context).getVariableText( - ptText: 'Aprovar Visita', - enText: 'Approve Visit', - ), - ), - content: Text( - FFLocalizations.of(context).getVariableText( - ptText: - 'Você tem certeza que deseja aprovar essa visita?', - enText: - 'Are you sure you want to approve this visit?', - ), - ), - backgroundColor: FlutterFlowTheme.of(context) - .primaryBackground, - actions: [ - FFButtonWidget( - text: FFLocalizations.of(context) - .getVariableText( - enText: 'No', - ptText: 'Não', - ), - onPressed: () { - context.pop(); - }, - options: FFButtonOptions( - width: 100, - height: 40, - color: FlutterFlowTheme.of(context) - .primaryBackground, - textStyle: TextStyle( - color: FlutterFlowTheme.of(context) - .primaryText, - ), - borderSide: BorderSide( - color: FlutterFlowTheme.of(context) - .primaryBackground, - width: 1, - ), - borderRadius: - BorderRadius.circular(10)), - ), - FFButtonWidget( - text: FFLocalizations.of(context) - .getVariableText( - enText: 'Yes', - ptText: 'Sim', - ), - onPressed: () async { - log("payload: $payload"); - await answersRequest - .call( - context, - payload['referencia'].toString(), - 'L', - 'Mensagem', - payload['idVisitante'].toString(), - ) - .then((value) { - if (value) { - context.pop(); - context.pop(); - } else { - context.pop(); - context.pop(); - DialogUtil.errorDefault(context); - } - }).catchError((e) { - context.pop(); - context.pop(); - DialogUtil.errorDefault(context); - }); - }, - options: FFButtonOptions( - width: 100, - height: 40, - color: FlutterFlowTheme.of(context) - .primaryBackground, - textStyle: TextStyle( - color: FlutterFlowTheme.of(context) - .primaryText, - ), - borderSide: BorderSide( - color: FlutterFlowTheme.of(context) - .primaryBackground, - width: 1, - ), - borderRadius: BorderRadius.circular(10), - ), - ), - ], - ); + showAlertDialog( + context, + FFLocalizations.of(context).getVariableText( + ptText: 'Aprovar Visita', + enText: 'Approve Visit', + ), + FFLocalizations.of(context).getVariableText( + ptText: + 'Você tem certeza que deseja aprovar essa visita?', + enText: + 'Are you sure you want to approve this visit?', + ), + () async { + log("payload: $payload"); + await answersRequest + .call( + context, + payload['referencia'].toString(), + 'L', + 'Mensagem', + payload['idVisitante'].toString(), + ) + .then((value) { + if (value) { + context.pop(); + context.pop(); + } else { + context.pop(); + context.pop(); + DialogUtil.errorDefault(context); + } + }).catchError((e) { + context.pop(); + context.pop(); + DialogUtil.errorDefault(context); }); + }, + ); }, ), FlutterFlowIconButton( diff --git a/lib/main.dart b/lib/main.dart index 3e21b787..faafd27a 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -93,7 +93,9 @@ class _AppState extends State { FirebaseMessaging.onMessage.listen(foregroundHandleMessage); FirebaseMessaging.onMessageOpenedApp.listen((RemoteMessage message) { - onMessageReceived(message.data, '', message.data['click_action']); + log(message.toMap().toString()); + onMessageReceived(message.data, message.notification!.body, + message.data['click_action']); }); FirebaseMessaging.onBackgroundMessage(_backgroundHandleMessage);