fix homePage nav on enroll_cond
This commit is contained in:
parent
994862bed5
commit
58ddd9391d
|
@ -3,6 +3,7 @@ import 'dart:convert';
|
|||
import 'dart:developer';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:hub/backend/notifications/firebase_messaging_service.dart';
|
||||
import 'package:hub/shared/helpers/db_helper.dart';
|
||||
import 'package:hub/shared/utils/validator_util.dart';
|
||||
|
||||
|
@ -674,6 +675,7 @@ class LoginCall {
|
|||
final password = AppState().passwd;
|
||||
final type = AppState().deviceType;
|
||||
final description = AppState().deviceDescription;
|
||||
final token = FirebaseMessagingService.getToken();
|
||||
|
||||
return ApiManager.instance.makeApiCall(
|
||||
callName: 'login',
|
||||
|
@ -686,6 +688,7 @@ class LoginCall {
|
|||
'email': email,
|
||||
'password': password,
|
||||
'uuid': devUUID,
|
||||
'token': token,
|
||||
'tipo': type,
|
||||
'descricao': description,
|
||||
},
|
||||
|
|
|
@ -56,6 +56,9 @@ class FirebaseMessagingService {
|
|||
// });
|
||||
}
|
||||
|
||||
static Future<String> getToken() async =>
|
||||
await FirebaseMessaging.instance.getToken() ?? '';
|
||||
|
||||
Future<void> updateDeviceToken() async {
|
||||
try {
|
||||
final String? deviceToken = await _firebaseMessaging.getToken();
|
||||
|
|
|
@ -255,6 +255,8 @@ Future<void> onMessageReceived(
|
|||
|
||||
break;
|
||||
case 'enroll_cond':
|
||||
AppState().haveLocal = true;
|
||||
AppState().context!.go('/homePage');
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
|
@ -55,6 +55,12 @@ Future<void> initializeApp() async {
|
|||
}
|
||||
|
||||
Future<void> foregroundHandleMessage(RemoteMessage message) async {
|
||||
log('Foreground message received: ${message.data['click_action']}');
|
||||
|
||||
if (message.data['click_action'] == 'enroll_cond') {
|
||||
AppState().haveLocal = true;
|
||||
AppState().context!.go('/homePage');
|
||||
}
|
||||
if (!Platform.isIOS) {
|
||||
NotificationService.show(
|
||||
title: message.notification!.title!,
|
||||
|
@ -63,7 +69,13 @@ Future<void> foregroundHandleMessage(RemoteMessage message) async {
|
|||
}
|
||||
}
|
||||
|
||||
Future<void> _backgroundHandleMessage(RemoteMessage message) async {}
|
||||
Future<void> _backgroundHandleMessage(RemoteMessage message) async {
|
||||
log('Background message received: ${message.data}');
|
||||
if (message.data['click_action'] == 'enroll_cond') {
|
||||
AppState().haveLocal = true;
|
||||
AppState().context!.go('/homePage');
|
||||
}
|
||||
}
|
||||
|
||||
void main() async {
|
||||
await initializeApp();
|
||||
|
|
|
@ -1,32 +0,0 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
class NoConnectionScreen extends StatelessWidget {
|
||||
const NoConnectionScreen({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Sem Conexão'),
|
||||
),
|
||||
body: Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const Icon(Icons.signal_wifi_off, size: 80),
|
||||
const SizedBox(height: 20),
|
||||
const Text(
|
||||
'Você está offline. Verifique sua conexão com a internet.'),
|
||||
const SizedBox(height: 20),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
// Tente reconectar
|
||||
},
|
||||
child: const Text('Tentar Novamente'),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:hub/backend/api_requests/api_calls.dart';
|
||||
import 'package:hub/backend/notifications/firebase_messaging_service.dart';
|
||||
import 'package:hub/components/atomic_components/shared_components_atoms/atom_image_svg_theme.dart';
|
||||
import 'package:hub/flutter_flow/flutter_flow_theme.dart';
|
||||
import 'package:hub/flutter_flow/flutter_flow_util.dart';
|
||||
|
@ -17,8 +18,15 @@ class ReceptionPageWidget extends StatefulWidget {
|
|||
}
|
||||
|
||||
class _ReceptionPageWidgetState extends State<ReceptionPageWidget> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
FirebaseMessagingService().updateDeviceToken();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
AppState().context = context;
|
||||
return ChangeNotifierProvider(
|
||||
create: (context) => ReceptionPageModel(),
|
||||
child: Scaffold(
|
||||
|
|
Loading…
Reference in New Issue