From 11e17c3b4da66ec4c0a625937727ba78f10432d2 Mon Sep 17 00:00:00 2001 From: ManhNTX Date: Fri, 18 Nov 2022 12:09:07 +0700 Subject: [PATCH] TF-1202: Config Podfile for FCM --- android/app/build.gradle | 1 - android/app/src/main/AndroidManifest.xml | 5 + ios/Podfile | 2 +- ios/Podfile.lock | 87 ++++++++++++++- ios/Runner.xcodeproj/project.pbxproj | 7 ++ lib/features/base/base_controller.dart | 8 +- .../mailbox_dashboard_controller.dart | 5 +- .../presentation/firebase_options.dart | 8 +- .../presentation/notification_service.dart | 103 +----------------- .../presentation/notification_strings.dart | 54 --------- lib/main.dart | 5 +- pubspec.lock | 28 ----- pubspec.yaml | 3 +- 13 files changed, 116 insertions(+), 200 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index 0b4826176..ccfae58f0 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -22,7 +22,6 @@ if (flutterVersionName == null) { } apply plugin: 'com.android.application' -apply plugin: 'com.google.gms.google-services' apply plugin: 'kotlin-android' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index a8ddaba77..af0b19a26 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -91,6 +91,11 @@ + + 10.1.0) + - firebase_core (2.2.0): + - Firebase/CoreOnly (= 10.1.0) + - Flutter + - firebase_messaging (14.1.0): + - Firebase/Messaging (= 10.1.0) + - firebase_core + - Flutter + - FirebaseCore (10.1.0): + - FirebaseCoreInternal (~> 10.0) + - GoogleUtilities/Environment (~> 7.8) + - GoogleUtilities/Logger (~> 7.8) + - FirebaseCoreInternal (10.2.0): + - "GoogleUtilities/NSData+zlib (~> 7.8)" + - FirebaseInstallations (10.2.0): + - FirebaseCore (~> 10.0) + - GoogleUtilities/Environment (~> 7.8) + - GoogleUtilities/UserDefaults (~> 7.8) + - PromisesObjC (~> 2.1) + - FirebaseMessaging (10.1.0): + - FirebaseCore (~> 10.0) + - FirebaseInstallations (~> 10.0) + - GoogleDataTransport (~> 9.2) + - GoogleUtilities/AppDelegateSwizzler (~> 7.8) + - GoogleUtilities/Environment (~> 7.8) + - GoogleUtilities/Reachability (~> 7.8) + - GoogleUtilities/UserDefaults (~> 7.8) + - nanopb (< 2.30910.0, >= 2.30908.0) - fk_user_agent (2.0.0): - Flutter - Flutter (1.0.0) @@ -77,6 +109,27 @@ PODS: - FMDB (2.7.5): - FMDB/standard (= 2.7.5) - FMDB/standard (2.7.5) + - GoogleDataTransport (9.2.0): + - GoogleUtilities/Environment (~> 7.7) + - nanopb (< 2.30910.0, >= 2.30908.0) + - PromisesObjC (< 3.0, >= 1.2) + - GoogleUtilities/AppDelegateSwizzler (7.10.0): + - GoogleUtilities/Environment + - GoogleUtilities/Logger + - GoogleUtilities/Network + - GoogleUtilities/Environment (7.10.0): + - PromisesObjC (< 3.0, >= 1.2) + - GoogleUtilities/Logger (7.10.0): + - GoogleUtilities/Environment + - GoogleUtilities/Network (7.10.0): + - GoogleUtilities/Logger + - "GoogleUtilities/NSData+zlib" + - GoogleUtilities/Reachability + - "GoogleUtilities/NSData+zlib (7.10.0)" + - GoogleUtilities/Reachability (7.10.0): + - GoogleUtilities/Logger + - GoogleUtilities/UserDefaults (7.10.0): + - GoogleUtilities/Logger - libwebp (1.2.3): - libwebp/demux (= 1.2.3) - libwebp/mux (= 1.2.3) @@ -89,6 +142,11 @@ PODS: - Mantle (2.2.0): - Mantle/extobjc (= 2.2.0) - Mantle/extobjc (2.2.0) + - nanopb (2.30909.0): + - nanopb/decode (= 2.30909.0) + - nanopb/encode (= 2.30909.0) + - nanopb/decode (2.30909.0) + - nanopb/encode (2.30909.0) - OrderedSet (5.0.0) - package_info_plus (0.4.5): - Flutter @@ -96,6 +154,7 @@ PODS: - Flutter - permission_handler_apple (9.0.4): - Flutter + - PromisesObjC (2.1.1) - ReachabilitySwift (5.0.0) - receive_sharing_intent (0.0.1): - Flutter @@ -125,6 +184,8 @@ DEPENDENCIES: - contacts_service (from `.symlinks/plugins/contacts_service/ios`) - device_info_plus (from `.symlinks/plugins/device_info_plus/ios`) - file_picker (from `.symlinks/plugins/file_picker/ios`) + - firebase_core (from `.symlinks/plugins/firebase_core/ios`) + - firebase_messaging (from `.symlinks/plugins/firebase_messaging/ios`) - fk_user_agent (from `.symlinks/plugins/fk_user_agent/ios`) - Flutter (from `Flutter`) - flutter_appauth (from `.symlinks/plugins/flutter_appauth/ios`) @@ -149,10 +210,19 @@ SPEC REPOS: - AppAuth - DKImagePickerController - DKPhotoGallery + - Firebase + - FirebaseCore + - FirebaseCoreInternal + - FirebaseInstallations + - FirebaseMessaging - FMDB + - GoogleDataTransport + - GoogleUtilities - libwebp - Mantle + - nanopb - OrderedSet + - PromisesObjC - ReachabilitySwift - SDWebImage - SDWebImageWebPCoder @@ -170,6 +240,10 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/device_info_plus/ios" file_picker: :path: ".symlinks/plugins/file_picker/ios" + firebase_core: + :path: ".symlinks/plugins/firebase_core/ios" + firebase_messaging: + :path: ".symlinks/plugins/firebase_messaging/ios" fk_user_agent: :path: ".symlinks/plugins/fk_user_agent/ios" Flutter: @@ -216,6 +290,13 @@ SPEC CHECKSUMS: DKImagePickerController: b512c28220a2b8ac7419f21c491fc8534b7601ac DKPhotoGallery: fdfad5125a9fdda9cc57df834d49df790dbb4179 file_picker: 817ab1d8cd2da9d2da412a417162deee3500fc95 + Firebase: 444b35a9c568a516666213c2f6cccd10cb12559f + firebase_core: d2242c6f318db1d0dcecfbfa491e943337b0d755 + firebase_messaging: 59f435c4cd0d5448e7268a7f70bce9b1287c1742 + FirebaseCore: 55e7ae35991ccca4db03ff8d8df6ed5f17a3e4c7 + FirebaseCoreInternal: 091bde13e47bb1c5e9fe397634f3593dc390430f + FirebaseInstallations: 004915af170935e3a583faefd5f8bc851afc220f + FirebaseMessaging: 4487bbff9b9b927ba1dd3ea40d1ceb58e4ee3cb5 fk_user_agent: 1f47ec39291e8372b1d692b50084b0d54103c545 Flutter: 50d75fe2f02b26cc09d224853bb45737f8b3214a flutter_appauth: 05c3778a1e4ae23364dd2ef37cbae14b244f646b @@ -226,12 +307,16 @@ SPEC CHECKSUMS: flutter_native_splash: 52501b97d1c0a5f898d687f1646226c1f93c56ef fluttertoast: 6122fa75143e992b1d3470f61000f591a798cc58 FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a + GoogleDataTransport: 1c8145da7117bd68bbbed00cf304edb6a24de00f + GoogleUtilities: bad72cb363809015b1f7f19beb1f1cd23c589f95 libwebp: 60305b2e989864154bd9be3d772730f08fc6a59c Mantle: c5aa8794a29a022dfbbfc9799af95f477a69b62d + nanopb: b552cce312b6c8484180ef47159bc0f65a1f0431 OrderedSet: aaeb196f7fef5a9edf55d89760da9176ad40b93c package_info_plus: 6c92f08e1f853dc01228d6f553146438dafcd14e path_provider: abfe2b5c733d04e238b0d8691db0cfd63a27a93c permission_handler_apple: 44366e37eaf29454a1e7b1b7d736c2cceaeb17ce + PromisesObjC: ab77feca74fa2823e7af4249b8326368e61014cb ReachabilitySwift: 985039c6f7b23a1da463388634119492ff86c825 receive_sharing_intent: c0d87310754e74c0f9542947e7cbdf3a0335a3b1 SDWebImage: af5bbffef2cde09f148d826f9733dcde1a9414cd @@ -244,6 +329,6 @@ SPEC CHECKSUMS: url_launcher_ios: 839c58cdb4279282219f5e248c3321761ff3c4de webview_flutter_wkwebview: b7e70ef1ddded7e69c796c7390ee74180182971f -PODFILE CHECKSUM: 91efd4097cc41f032416d67ecaac21cc2de8dd55 +PODFILE CHECKSUM: e209bf81fb4facf3f68c43dbffa0b2d05ff63db0 COCOAPODS: 1.11.3 diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 1113f4cca..827881814 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + 0FCA69E45174F1DF02B9350B /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 514B9D0F73F09C5EF676EF94 /* GoogleService-Info.plist */; }; 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; 6DD0BB4CA9591742B94CC3B6 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0F5F6A3907EC26183773A828 /* Pods_Runner.framework */; }; @@ -59,6 +60,7 @@ 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; + 514B9D0F73F09C5EF676EF94 /* GoogleService-Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; name = "GoogleService-Info.plist"; path = "Runner/GoogleService-Info.plist"; sourceTree = ""; }; 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; @@ -126,6 +128,7 @@ 97C146EF1CF9000F007C117D /* Products */, F62B48DC0DFBD6D5D355E5FE /* Pods */, 66B148CBFC3A1B0ADAE68790 /* Frameworks */, + 514B9D0F73F09C5EF676EF94 /* GoogleService-Info.plist */, ); sourceTree = ""; }; @@ -266,6 +269,7 @@ 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */, 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */, + 0FCA69E45174F1DF02B9350B /* GoogleService-Info.plist in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -469,6 +473,7 @@ DEVELOPMENT_TEAM = KUT463DS29; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -603,6 +608,7 @@ DEVELOPMENT_TEAM = KUT463DS29; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -631,6 +637,7 @@ DEVELOPMENT_TEAM = KUT463DS29; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", diff --git a/lib/features/base/base_controller.dart b/lib/features/base/base_controller.dart index 3d8ffef27..0708f73c3 100644 --- a/lib/features/base/base_controller.dart +++ b/lib/features/base/base_controller.dart @@ -1,8 +1,6 @@ import 'package:contact/contact/model/capability_contact.dart'; import 'package:core/core.dart'; import 'package:dartz/dartz.dart'; -import 'package:firebase_core/firebase_core.dart'; -import 'package:firebase_messaging/firebase_messaging.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:forward/forward/capability_forward.dart'; @@ -21,8 +19,6 @@ import 'package:tmail_ui_user/features/manage_account/presentation/email_rules/b import 'package:tmail_ui_user/features/manage_account/presentation/forward/bindings/forwarding_interactors_bindings.dart'; import 'package:tmail_ui_user/features/push_notification/domain/model/capability_push_notification.dart'; import 'package:tmail_ui_user/features/push_notification/presentation/firebase_bindings.dart'; -import 'package:tmail_ui_user/features/push_notification/presentation/firebase_options.dart'; -import 'package:tmail_ui_user/features/push_notification/presentation/notification_service.dart'; import 'package:tmail_ui_user/main/error/capability_validator.dart'; import 'package:tmail_ui_user/main/exceptions/remote_exception.dart'; import 'package:tmail_ui_user/main/localizations/app_localizations.dart'; @@ -147,11 +143,9 @@ abstract class BaseController extends GetxController } } - Future injectFirebaseBindings(Session? session, AccountId? accountId) async { + void injectFirebaseBindings(Session? session, AccountId? accountId) { try { requireCapability(session!, accountId!, [capabilityPushNotification]); - await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform); - FirebaseMessaging.onBackgroundMessage(firebaseMessagingBackgroundHandler); FireBaseBindings().dependencies(); } catch(e) { logError('BaseController::injectFirebaseBindings(): exception: $e'); diff --git a/lib/features/mailbox_dashboard/presentation/controller/mailbox_dashboard_controller.dart b/lib/features/mailbox_dashboard/presentation/controller/mailbox_dashboard_controller.dart index 19cf902c9..63c39559f 100644 --- a/lib/features/mailbox_dashboard/presentation/controller/mailbox_dashboard_controller.dart +++ b/lib/features/mailbox_dashboard/presentation/controller/mailbox_dashboard_controller.dart @@ -358,10 +358,9 @@ class MailboxDashBoardController extends ReloadableController { @override Future injectFirebaseBindings(Session? session, AccountId? accountId) async { try { - await super.injectFirebaseBindings(session, accountId); + super.injectFirebaseBindings(session, accountId); _saveFirebaseCacheInteractor = Get.find(); - NotificationService.initializeNotificationService( - onDidReceiveNotificationResponse); + await NotificationService.initializeNotificationService(); NotificationService.onTokenRefresh.listen((token) { _saveFirebaseCacheInteractor?.execute(FirebaseDto(token)); }); diff --git a/lib/features/push_notification/presentation/firebase_options.dart b/lib/features/push_notification/presentation/firebase_options.dart index ed326fe69..281814d6c 100644 --- a/lib/features/push_notification/presentation/firebase_options.dart +++ b/lib/features/push_notification/presentation/firebase_options.dart @@ -18,17 +18,17 @@ class DefaultFirebaseOptions { case TargetPlatform.macOS: throw UnsupportedError( 'DefaultFirebaseOptions have not been configured for macos - ' - 'you can reconfigure this by running the FlutterFire CLI again.', + 'you can reconfigure this by running the FlutterFire CLI again.', ); case TargetPlatform.windows: throw UnsupportedError( 'DefaultFirebaseOptions have not been configured for windows - ' - 'you can reconfigure this by running the FlutterFire CLI again.', + 'you can reconfigure this by running the FlutterFire CLI again.', ); case TargetPlatform.linux: throw UnsupportedError( 'DefaultFirebaseOptions have not been configured for linux - ' - 'you can reconfigure this by running the FlutterFire CLI again.', + 'you can reconfigure this by running the FlutterFire CLI again.', ); default: throw UnsupportedError( @@ -66,4 +66,4 @@ class DefaultFirebaseOptions { iosClientId: dotenv.get('FIREBASE_IOS_CLIENT_ID', fallback: ''), iosBundleId: dotenv.get('FIREBASE_IOS_BUNDLE_ID', fallback: ''), ); -} +} \ No newline at end of file diff --git a/lib/features/push_notification/presentation/notification_service.dart b/lib/features/push_notification/presentation/notification_service.dart index 84e814234..4b2ee73c2 100644 --- a/lib/features/push_notification/presentation/notification_service.dart +++ b/lib/features/push_notification/presentation/notification_service.dart @@ -1,36 +1,19 @@ import 'dart:async'; -import 'dart:io'; +import 'package:core/utils/app_logger.dart'; import 'package:firebase_core/firebase_core.dart'; import 'package:firebase_messaging/firebase_messaging.dart'; -import 'package:flutter/foundation.dart'; import 'package:flutter_dotenv/flutter_dotenv.dart'; -import 'package:flutter_local_notifications/flutter_local_notifications.dart'; import 'package:get/get.dart'; import 'package:model/firebase/firebase_dto.dart'; import 'package:tmail_ui_user/features/push_notification/domain/usecases/save_firebase_cache_interactor.dart'; import 'package:tmail_ui_user/features/push_notification/presentation/firebase_options.dart'; -import 'notification_strings.dart'; - -final StreamController selectNotificationStream = -StreamController.broadcast(); @pragma('vm:entry-point') Future firebaseMessagingBackgroundHandler(RemoteMessage message) async { await dotenv.load(fileName: 'env.file'); await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform); - await NotificationService.displayPushNotification(message); -} - -@pragma('vm:entry-point') -void notificationTapBackground(NotificationResponse notificationResponse) { - //handle action -} - -void onDidReceiveNotificationResponse( - NotificationResponse details, - ) { - selectNotificationStream.add(details); + log('firebaseMessagingBackgroundHandler: ${message.data}'); } class NotificationService { @@ -42,53 +25,20 @@ class NotificationService { static get _firebaseMessaging => FirebaseMessaging.instance; - static get _flutterLocalNotificationsPlugin => - FlutterLocalNotificationsPlugin(); - static Stream get onTokenRefresh => _firebaseMessaging.onTokenRefresh; static bool _isFlutterLocalNotificationsInitialized = false; - static Future initializeNotificationService( - Function(NotificationResponse)? onDidReceiveNotificationResponse, - ) async { + static Future initializeNotificationService() async { + await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform); + FirebaseMessaging.onBackgroundMessage(firebaseMessagingBackgroundHandler); if (_isFlutterLocalNotificationsInitialized) return; final _saveFirebaseCacheInteractor = Get.find(); final token = await _firebaseMessaging.getToken(); _saveFirebaseCacheInteractor.execute(FirebaseDto(token)); await _initFirebaseMessaging(); - await _flutterLocalNotificationsPlugin.initialize( - InitializationSettings( - android: androidInitializationSettings, - iOS: iosInitializationSettings, - ), - onDidReceiveNotificationResponse: onDidReceiveNotificationResponse, - onDidReceiveBackgroundNotificationResponse: notificationTapBackground, - ); - await _requestPermissions(); - await _createNotificationChannels(); - _listenNotificationActionStream(); _isFlutterLocalNotificationsInitialized = true; } - static Future displayPushNotification( - RemoteMessage notification, - ) async { - try { - await _flutterLocalNotificationsPlugin.show( - createUniqueId, - channelName, - notification.data.toString(), - pushNotificationDetails, - ); - } catch (e) { - debugPrint(e.toString()); - } - } - - static Future cancelAllNotifications() async { - await _flutterLocalNotificationsPlugin.cancelAll(); - } - static Future _initFirebaseMessaging() async { FirebaseMessaging.onMessage.listen(_handleIncomingForegroundNotification); FirebaseMessaging.onMessageOpenedApp.listen(_handleOpenedAppNotification); @@ -97,52 +47,11 @@ class NotificationService { static Future _handleIncomingForegroundNotification( RemoteMessage remoteMessage, ) async { - await displayPushNotification(remoteMessage); + log('firebaseMessagingForegroundHandler: ${remoteMessage.data}'); } static void _handleOpenedAppNotification(RemoteMessage remoteMessage) {} - static Future _requestPermissions() async { - if (Platform.isAndroid) { - await _flutterLocalNotificationsPlugin - .resolvePlatformSpecificImplementation< - AndroidFlutterLocalNotificationsPlugin>() - ?.requestPermission(); - } else { - await _flutterLocalNotificationsPlugin - .resolvePlatformSpecificImplementation< - IOSFlutterLocalNotificationsPlugin>() - ?.requestPermissions( - alert: true, - badge: true, - sound: true, - ); - } - } - - static Future _listenNotificationActionStream() async { - selectNotificationStream.stream - .listen((event) => event) - .onData((data) async { - switch (data?.notificationResponseType) { - case NotificationResponseType.selectedNotification: - break; - case NotificationResponseType.selectedNotificationAction: - break; - default: - } - }); - } - - static Future _createNotificationChannels() async { - await _flutterLocalNotificationsPlugin - .resolvePlatformSpecificImplementation< - AndroidFlutterLocalNotificationsPlugin>() - ?.createNotificationChannel(androidChannel); - } static Future deleteToken() async => _firebaseMessaging.deleteToken(); } - -int get createUniqueId => - DateTime.now().millisecondsSinceEpoch.remainder(100000); diff --git a/lib/features/push_notification/presentation/notification_strings.dart b/lib/features/push_notification/presentation/notification_strings.dart index c952e22d0..e69de29bb 100644 --- a/lib/features/push_notification/presentation/notification_strings.dart +++ b/lib/features/push_notification/presentation/notification_strings.dart @@ -1,54 +0,0 @@ -import 'package:flutter_local_notifications/flutter_local_notifications.dart'; - -const channelId = 'team_mail_channel_id'; -const channelKey = 'team_mail_channel_key'; -const channelName = 'Team Mail notifications'; -const channelDescription = 'Team Mail notifications'; - -final iosInitializationSettings = DarwinInitializationSettings( - notificationCategories: [ - DarwinNotificationCategory( - channelId, - actions: [ - DarwinNotificationAction.plain( - channelKey, - channelName, - options: { - DarwinNotificationActionOption.foreground, - }, - ), - ], - ), - ], - onDidReceiveLocalNotification: - (int id, String? title, String? body, String? payload) {}, -); - -const androidInitializationSettings = -AndroidInitializationSettings('background'); - -const androidChannel = AndroidNotificationChannel( - channelId, - channelName, - description: channelDescription, - importance: Importance.max, - enableLights: true, -); - -const pushNotificationDetails = NotificationDetails( - android: AndroidNotificationDetails( - channelId, - channelName, - channelDescription: channelDescription, - visibility: NotificationVisibility.public, - importance: Importance.max, - ledOnMs: 100, - ledOffMs: 1000, - category: AndroidNotificationCategory.message, - ), - iOS: DarwinNotificationDetails( - presentSound: true, - presentAlert: true, - presentBadge: true, - ), -); \ No newline at end of file diff --git a/lib/main.dart b/lib/main.dart index 6eeb9b775..6c7a85fea 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,10 +1,11 @@ import 'package:core/core.dart'; +import 'package:firebase_core/firebase_core.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; -import 'package:flutter_dotenv/flutter_dotenv.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:get/get.dart'; import 'package:tmail_ui_user/features/caching/config/hive_cache_config.dart'; +import 'package:tmail_ui_user/features/push_notification/presentation/firebase_options.dart'; import 'package:tmail_ui_user/main/bindings/main_bindings.dart'; import 'package:tmail_ui_user/main/localizations/app_localizations.dart'; import 'package:tmail_ui_user/main/localizations/app_localizations_delegate.dart'; @@ -14,6 +15,7 @@ import 'package:tmail_ui_user/main/routes/app_routes.dart'; import 'package:worker_manager/worker_manager.dart'; void main() async { + await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform); initLogger(() async { WidgetsFlutterBinding.ensureInitialized(); SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle( @@ -26,7 +28,6 @@ void main() async { await HiveCacheConfig().setUp(); await HiveCacheConfig.initializeEncryptionKey(); await Executor().warmUp(); - await dotenv.load(fileName: 'env.file'); runApp(const TMailApp()); }); } diff --git a/pubspec.lock b/pubspec.lock index 4e75c6bbe..c116063bd 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -623,27 +623,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.0.4" - flutter_local_notifications: - dependency: "direct main" - description: - name: flutter_local_notifications - url: "https://pub.dartlang.org" - source: hosted - version: "12.0.3+1" - flutter_local_notifications_linux: - dependency: transitive - description: - name: flutter_local_notifications_linux - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.0" - flutter_local_notifications_platform_interface: - dependency: transitive - description: - name: flutter_local_notifications_platform_interface - url: "https://pub.dartlang.org" - source: hosted - version: "6.0.0" flutter_localizations: dependency: "direct main" description: flutter @@ -1407,13 +1386,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "3.2.2" - timezone: - dependency: transitive - description: - name: timezone - url: "https://pub.dartlang.org" - source: hosted - version: "0.9.0" timing: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 483d69f6c..63d2bae86 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -196,9 +196,8 @@ dependencies: ref: master url_launcher: 6.1.5 - firebase_core: ^2.2.0 + firebase_core: 2.2.0 firebase_messaging: 14.0.4 - flutter_local_notifications: ^12.0.3 dev_dependencies: flutter_test: