Protótipo Vilacorp
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:decpisos/atualizarapp/atualizarapp.dart';
|
||||
import 'package:decpisos/index/index.dart';
|
||||
import 'package:decpisos/notificacoes/notificacoes.dart';
|
||||
import 'package:vilacorp/atualizarapp/atualizarapp.dart';
|
||||
import 'package:vilacorp/index/index.dart';
|
||||
import 'package:vilacorp/notificacoes/notificacoes.dart';
|
||||
import 'package:firebase_messaging/firebase_messaging.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
@@ -12,11 +12,10 @@ import 'package:shared_preferences/shared_preferences.dart';
|
||||
import '../funcoes_gerais.dart';
|
||||
|
||||
class SplashController extends GetxController {
|
||||
|
||||
//bool _tutorialOk = false;
|
||||
//FirebaseMessaging _firebaseMessaging = FirebaseMessaging();
|
||||
//FirebaseMessaging _firebaseMessaging = FirebaseMessaging.instance;
|
||||
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
@@ -29,26 +28,23 @@ class SplashController extends GetxController {
|
||||
|
||||
// Future<void> verTutorial()async{
|
||||
// SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
// this._tutorialOk = prefs.getBool('tutorial') ?? false;
|
||||
// this._tutorialOk = prefs.getBool('tutorial') ?? false;
|
||||
// }
|
||||
|
||||
Future<Widget> verUsuLogado()async{
|
||||
Future<Widget> verUsuLogado() async {
|
||||
var resp = await FuncoesGerais.checkVersaoMinimaOk();
|
||||
if(resp.vOk!){
|
||||
if (resp.vOk!) {
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
var token = prefs.getString('token_notif');
|
||||
await FuncoesGerais.registraDevice(token);
|
||||
return IndexScreen();
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
return AtualizarScreen(linkLoja: resp.linkLoja);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> firebaseCloudMessagingListeners() async{
|
||||
Future<void> firebaseCloudMessagingListeners() async {
|
||||
try {
|
||||
|
||||
//if (_firebaseMessaging == null) return;
|
||||
|
||||
if (Platform.isIOS) iOSPermission();
|
||||
@@ -58,7 +54,7 @@ class SplashController extends GetxController {
|
||||
// SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
// await prefs.setString('token_notif', token);
|
||||
// });
|
||||
FirebaseMessaging.instance.getToken().then((token) async{
|
||||
FirebaseMessaging.instance.getToken().then((token) async {
|
||||
print(token);
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
await prefs.setString('token_notif', token!);
|
||||
@@ -69,26 +65,28 @@ class SplashController extends GetxController {
|
||||
// //onBackgroundMessage: this._onNotification,
|
||||
// onResume: this._onNotification
|
||||
// );
|
||||
FirebaseMessaging.onMessage.listen((RemoteMessage message) {
|
||||
FirebaseMessaging.onMessage.listen((RemoteMessage message) {
|
||||
print('Push onMessage');
|
||||
Get.snackbar(message.notification!.title ?? 'Notificação', message.notification!.body ?? 'Nova notificação',
|
||||
mainButton: TextButton(onPressed: () => this._onNotification(message), child: Text('Ver')),
|
||||
backgroundColor: Colors.black.withOpacity(0.7),
|
||||
colorText: Colors.white
|
||||
);
|
||||
Get.snackbar(message.notification!.title ?? 'Notificação',
|
||||
message.notification!.body ?? 'Nova notificação',
|
||||
mainButton: TextButton(
|
||||
onPressed: () => this._onNotification(message),
|
||||
child: Text('Ver')),
|
||||
backgroundColor: Colors.black.withOpacity(0.7),
|
||||
colorText: Colors.white);
|
||||
//this._onNotification(message);
|
||||
});
|
||||
FirebaseMessaging.onMessageOpenedApp.listen((RemoteMessage message) {
|
||||
print('A new onMessageOpenedApp event was published!');
|
||||
print(message);
|
||||
//Get.snackbar(message.notification!.title ?? 'Notificação', message.notification!.body ?? 'Nova notificação',mainButton: TextButton(onPressed: () => this._onNotification(message), child: Text('Ver')));
|
||||
});
|
||||
});
|
||||
} on PlatformException catch (e) {
|
||||
print(e.message);
|
||||
}
|
||||
}
|
||||
|
||||
void _onNotification(RemoteMessage message){
|
||||
void _onNotification(RemoteMessage message) {
|
||||
Get.to(() => NotificacoesScreen());
|
||||
//print(message);
|
||||
//print(message['aps']['alert']['title']);
|
||||
@@ -103,7 +101,5 @@ class SplashController extends GetxController {
|
||||
// .listen((IosNotificationSettings settings) {
|
||||
// print("Settings registered: $settings");
|
||||
// });
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user