WIP
This commit is contained in:
parent
ee4c257710
commit
9891165ca9
|
@ -0,0 +1,62 @@
|
||||||
|
import 'dart:developer';
|
||||||
|
|
||||||
|
import 'package:app_tracking_transparency/app_tracking_transparency.dart';
|
||||||
|
import 'package:firebase_core/firebase_core.dart';
|
||||||
|
import 'package:firebase_crashlytics/firebase_crashlytics.dart';
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
|
import 'package:flutter_web_plugins/url_strategy.dart';
|
||||||
|
import 'package:hub/backend/notifications/notification_service.dart';
|
||||||
|
import 'package:hub/flutter_flow/flutter_flow_theme.dart';
|
||||||
|
import 'package:hub/flutter_flow/flutter_flow_util.dart';
|
||||||
|
import 'package:hub/flutter_flow/nav/nav.dart';
|
||||||
|
import 'package:hub/shared/helpers/storage/storage_helper.dart';
|
||||||
|
import 'package:hub/shared/services/localization/localization_service.dart';
|
||||||
|
|
||||||
|
Future<void> initializeApp() async {
|
||||||
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
|
await _initializeTracking();
|
||||||
|
await StorageHelper().init();
|
||||||
|
|
||||||
|
await _initializeFirebase();
|
||||||
|
await _initializeNotificationService();
|
||||||
|
_initializeUrlStrategy();
|
||||||
|
_initializeSystemSettings();
|
||||||
|
await _initializeFlutterFlow();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _initializeTracking() async {
|
||||||
|
await AppTrackingTransparency.requestTrackingAuthorization();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _initializeFirebase() async {
|
||||||
|
await Firebase.initializeApp();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _initializeNotificationService() async {
|
||||||
|
await NotificationService.initialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
void _initializeUrlStrategy() {
|
||||||
|
setUrlStrategy(PathUrlStrategy());
|
||||||
|
}
|
||||||
|
|
||||||
|
void _initializeSystemSettings() {
|
||||||
|
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
|
||||||
|
if (kDebugMode) {
|
||||||
|
log("Aplicativo em Debug Mode, crashlytics desabilitado!");
|
||||||
|
} else {
|
||||||
|
final crashlyticsInstance = FirebaseCrashlytics.instance;
|
||||||
|
if (crashlyticsInstance.isCrashlyticsCollectionEnabled) {
|
||||||
|
FlutterError.onError = crashlyticsInstance.recordFlutterError;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _initializeFlutterFlow() async {
|
||||||
|
await FlutterFlowTheme.initialize();
|
||||||
|
await FFLocalizations.initialize();
|
||||||
|
GoRouter.optionURLReflectsImperativeAPIs = true;
|
||||||
|
usePathUrlStrategy();
|
||||||
|
}
|
|
@ -22,64 +22,19 @@ import 'package:hub/shared/helpers/storage/storage_helper.dart';
|
||||||
import 'package:hub/shared/services/deeplink/deep_link_service.dart';
|
import 'package:hub/shared/services/deeplink/deep_link_service.dart';
|
||||||
import 'package:hub/shared/services/localization/localization_service.dart';
|
import 'package:hub/shared/services/localization/localization_service.dart';
|
||||||
import 'package:responsive_framework/responsive_framework.dart';
|
import 'package:responsive_framework/responsive_framework.dart';
|
||||||
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
|
||||||
import 'backend/notifications/firebase_messaging_service.dart';
|
import 'backend/notifications/firebase_messaging_service.dart';
|
||||||
|
import 'initialization.dart';
|
||||||
|
|
||||||
final GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();
|
final GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();
|
||||||
|
|
||||||
void main() async {
|
void main() async {
|
||||||
await initializeApp();
|
await initializeApp();
|
||||||
runApp(const App());
|
runApp(const ProviderScope(child: App()));
|
||||||
FirebaseMessaging.onBackgroundMessage(_backgroundHandlerMessage);
|
FirebaseMessaging.onBackgroundMessage(_backgroundHandlerMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> initializeApp() async {
|
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
|
||||||
await _initializeTracking();
|
|
||||||
await StorageHelper().init();
|
|
||||||
|
|
||||||
await _initializeFirebase();
|
|
||||||
await _initializeNotificationService();
|
|
||||||
_initializeUrlStrategy();
|
|
||||||
_initializeSystemSettings();
|
|
||||||
await _initializeFlutterFlow();
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _initializeTracking() async {
|
|
||||||
await AppTrackingTransparency.requestTrackingAuthorization();
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _initializeFirebase() async {
|
|
||||||
await Firebase.initializeApp();
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _initializeNotificationService() async {
|
|
||||||
await NotificationService.initialize();
|
|
||||||
}
|
|
||||||
|
|
||||||
void _initializeUrlStrategy() {
|
|
||||||
setUrlStrategy(PathUrlStrategy());
|
|
||||||
}
|
|
||||||
|
|
||||||
void _initializeSystemSettings() {
|
|
||||||
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
|
|
||||||
if (kDebugMode) {
|
|
||||||
log("Aplicativo em Debug Mode, crashlytics desabilitado!");
|
|
||||||
} else {
|
|
||||||
final crashlyticsInstance = FirebaseCrashlytics.instance;
|
|
||||||
if (crashlyticsInstance.isCrashlyticsCollectionEnabled) {
|
|
||||||
FlutterError.onError = crashlyticsInstance.recordFlutterError;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _initializeFlutterFlow() async {
|
|
||||||
await FlutterFlowTheme.initialize();
|
|
||||||
await FFLocalizations.initialize();
|
|
||||||
GoRouter.optionURLReflectsImperativeAPIs = true;
|
|
||||||
usePathUrlStrategy();
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _foregroundHandlerMessage(RemoteMessage message) async {
|
Future<void> _foregroundHandlerMessage(RemoteMessage message) async {
|
||||||
if (message.data['click_action'] == 'enroll_cond') {
|
if (message.data['click_action'] == 'enroll_cond') {
|
||||||
await StorageHelper().s(SecureStorageKey.haveLocal.value, true);
|
await StorageHelper().s(SecureStorageKey.haveLocal.value, true);
|
||||||
|
@ -246,7 +201,7 @@ class _AppState extends State<App> with WidgetsBindingObserver {
|
||||||
void didChangeAppLifecycleState(AppLifecycleState state) async {
|
void didChangeAppLifecycleState(AppLifecycleState state) async {
|
||||||
if (state == AppLifecycleState.detached) {
|
if (state == AppLifecycleState.detached) {
|
||||||
await LocalizationService.processLocals(context);
|
await LocalizationService.processLocals(context);
|
||||||
FirebaseMessagingService().updateDeviceToken();
|
await FirebaseMessagingService().updateDeviceToken();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -306,6 +306,7 @@ class LicenseHelper {
|
||||||
static Future<void> insertLicenseFoo(
|
static Future<void> insertLicenseFoo(
|
||||||
final List<String> key, final String display) async {
|
final List<String> key, final String display) async {
|
||||||
for (var element in key) {
|
for (var element in key) {
|
||||||
|
log('insertLicenseFoo($element, $display)');
|
||||||
DatabaseStorage.database.insert(
|
DatabaseStorage.database.insert(
|
||||||
tableLicense,
|
tableLicense,
|
||||||
{
|
{
|
||||||
|
|
|
@ -85,7 +85,7 @@ class LicenseService {
|
||||||
log('Salvando módulo: ${body.toString()}');
|
log('Salvando módulo: ${body.toString()}');
|
||||||
// if (body is Map<String, dynamic>) await StorageHelper().s(body['key'], '');
|
// if (body is Map<String, dynamic>) await StorageHelper().s(body['key'], '');
|
||||||
if (body is Map<String, dynamic>)
|
if (body is Map<String, dynamic>)
|
||||||
await StorageHelper().s(body['key'], body);
|
await LicenseHelper().s(body['key'], body);
|
||||||
// StorageHelper.getInstance(Storage.SQLiteStorage).set(key, value);
|
// StorageHelper.getInstance(Storage.SQLiteStorage).set(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue