83 lines
2.7 KiB
Dart
83 lines
2.7 KiB
Dart
import 'dart:io';
|
|
|
|
import 'package:firebase_core/firebase_core.dart';
|
|
import 'package:firebase_messaging/firebase_messaging.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:get_storage/get_storage.dart';
|
|
import 'package:ride/views/auth/captin/login_captin.dart';
|
|
import 'package:ride/views/auth/login_page.dart';
|
|
import 'package:ride/views/home/Captin/home_captin.dart';
|
|
import 'package:ride/views/lang/languages.dart';
|
|
|
|
import 'constant/box_name.dart';
|
|
import 'controller/firebase/firbase_messge.dart';
|
|
import 'controller/functions/location_permission.dart';
|
|
import 'controller/functions/locaton_controller.dart';
|
|
import 'controller/local/local_controller.dart';
|
|
import 'controller/local/translations.dart';
|
|
import 'firebase_options.dart';
|
|
import 'models/db_sql.dart';
|
|
import 'views/home/map_page.dart';
|
|
|
|
final box = GetStorage();
|
|
DbSql sql = DbSql.instance;
|
|
@pragma('vm:entry-point')
|
|
Future<void> backgroundMessageHandler(RemoteMessage message) async {
|
|
await Firebase.initializeApp();
|
|
print('===========back===${message.notification?.title}');
|
|
|
|
if (message.notification!.title == 'Sefer') {
|
|
// SendGpsNow().getSiteNotification();
|
|
}
|
|
}
|
|
|
|
void main() async {
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
await GetStorage.init();
|
|
if (Platform.isAndroid || Platform.isIOS) {
|
|
await Firebase.initializeApp(
|
|
options: DefaultFirebaseOptions.currentPlatform,
|
|
);
|
|
}
|
|
|
|
await FirebasMessagesController().requestFirebaseMessagingPermission();
|
|
// await FirebasMessagesController().getNotificationSettings();
|
|
await FirebasMessagesController().getToken();
|
|
await FirebasMessagesController().getTokens();
|
|
LocationPermissions().locationPermissions();
|
|
FirebaseMessaging.onBackgroundMessage(backgroundMessageHandler);
|
|
// if (box.read(BoxName.driverID) != null) {
|
|
// LocationController().startLocationUpdates();
|
|
// }
|
|
runApp(const MyApp());
|
|
}
|
|
|
|
class MyApp extends StatelessWidget {
|
|
const MyApp({super.key});
|
|
|
|
// This widget is the root of your application.
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
LocaleController controller = Get.put(LocaleController());
|
|
|
|
return GetMaterialApp(
|
|
title: 'Sefer',
|
|
translations: MyTranslation(),
|
|
debugShowCheckedModeBanner: false,
|
|
locale: controller.language,
|
|
theme: controller.appTheme,
|
|
key: UniqueKey(),
|
|
// routes: {'/':const HomePage()},
|
|
home: box.read(BoxName.lang).toString() != 'ar' &&
|
|
box.read(BoxName.lang).toString() != 'en'
|
|
? const Language()
|
|
: box.read(BoxName.email) != null
|
|
? const MapPage()
|
|
: box.read(BoxName.emailDriver) == null
|
|
? LoginCaptin()
|
|
: const HomeCaptin());
|
|
}
|
|
}
|