diff --git a/lib/main.dart b/lib/main.dart index 7bfd2ef..fedb5eb 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -15,14 +15,14 @@ import 'package:twonly/src/utils/misc.dart'; import 'src/app.dart'; void main() async { - final settingsController = SettingsChangeProvider(); + WidgetsFlutterBinding.ensureInitialized(); + await initFCMService(); + final settingsController = SettingsChangeProvider(); // Load the user's preferred theme while the splash screen is displayed. // This prevents a sudden theme change when the app is first displayed. await settingsController.loadSettings(); - WidgetsFlutterBinding.ensureInitialized(); - Logger.root.level = kReleaseMode ? Level.INFO : Level.ALL; Logger.root.onRecord.listen((record) { writeLogToFile(record); @@ -32,11 +32,10 @@ void main() async { } }); - await deleteLogFile(); + // await deleteLogFile(); await setupPushNotification(); await initMediaStorage(); - initFCMService(); gCameras = await availableCameras(); diff --git a/lib/src/services/fcm_service.dart b/lib/src/services/fcm_service.dart index 5ce6bdf..1665620 100644 --- a/lib/src/services/fcm_service.dart +++ b/lib/src/services/fcm_service.dart @@ -46,10 +46,21 @@ Future initFCMService() async { options: DefaultFirebaseOptions.currentPlatform, ); + FirebaseMessaging.onBackgroundMessage(_firebaseMessagingBackgroundHandler); + // You may set the permission requests to "provisional" which allows the user to choose what type // of notifications they would like to receive once the user receives a notification. // final notificationSettings = - await FirebaseMessaging.instance.requestPermission(provisional: true); + // await FirebaseMessaging.instance.requestPermission(provisional: true); + await FirebaseMessaging.instance.requestPermission( + alert: true, + announcement: false, + badge: true, + carPlay: false, + criticalAlert: false, + provisional: false, + sound: true, + ); // For apple platforms, ensure the APNS token is available before making any FCM plugin API calls if (Platform.isIOS) { @@ -61,8 +72,6 @@ Future initFCMService() async { // APNS token is available, make FCM plugin API requests... - FirebaseMessaging.onBackgroundMessage(_firebaseMessagingBackgroundHandler); - FirebaseMessaging.onMessage.listen((RemoteMessage message) { print('Got a message whilst in the foreground!'); print('Message data: ${message.data}'); diff --git a/pubspec.yaml b/pubspec.yaml index 21be0ee..d4dc527 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -4,7 +4,7 @@ description: "Send pictures to friends in real time and be sure you are the only # Prevent accidental publishing to pub.dev. publish_to: 'none' -version: 0.0.7+7 +version: 0.0.8+8 environment: sdk: ^3.6.0