This commit is contained in:
otsmr 2025-03-27 00:05:01 +01:00
parent ee4a6fe8cf
commit ad674dc77f
3 changed files with 17 additions and 9 deletions

View file

@ -15,14 +15,14 @@ import 'package:twonly/src/utils/misc.dart';
import 'src/app.dart'; import 'src/app.dart';
void main() async { 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. // Load the user's preferred theme while the splash screen is displayed.
// This prevents a sudden theme change when the app is first displayed. // This prevents a sudden theme change when the app is first displayed.
await settingsController.loadSettings(); await settingsController.loadSettings();
WidgetsFlutterBinding.ensureInitialized();
Logger.root.level = kReleaseMode ? Level.INFO : Level.ALL; Logger.root.level = kReleaseMode ? Level.INFO : Level.ALL;
Logger.root.onRecord.listen((record) { Logger.root.onRecord.listen((record) {
writeLogToFile(record); writeLogToFile(record);
@ -32,11 +32,10 @@ void main() async {
} }
}); });
await deleteLogFile(); // await deleteLogFile();
await setupPushNotification(); await setupPushNotification();
await initMediaStorage(); await initMediaStorage();
initFCMService();
gCameras = await availableCameras(); gCameras = await availableCameras();

View file

@ -46,10 +46,21 @@ Future initFCMService() async {
options: DefaultFirebaseOptions.currentPlatform, options: DefaultFirebaseOptions.currentPlatform,
); );
FirebaseMessaging.onBackgroundMessage(_firebaseMessagingBackgroundHandler);
// You may set the permission requests to "provisional" which allows the user to choose what type // 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. // of notifications they would like to receive once the user receives a notification.
// final notificationSettings = // 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 // For apple platforms, ensure the APNS token is available before making any FCM plugin API calls
if (Platform.isIOS) { if (Platform.isIOS) {
@ -61,8 +72,6 @@ Future initFCMService() async {
// APNS token is available, make FCM plugin API requests... // APNS token is available, make FCM plugin API requests...
FirebaseMessaging.onBackgroundMessage(_firebaseMessagingBackgroundHandler);
FirebaseMessaging.onMessage.listen((RemoteMessage message) { FirebaseMessaging.onMessage.listen((RemoteMessage message) {
print('Got a message whilst in the foreground!'); print('Got a message whilst in the foreground!');
print('Message data: ${message.data}'); print('Message data: ${message.data}');

View file

@ -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. # Prevent accidental publishing to pub.dev.
publish_to: 'none' publish_to: 'none'
version: 0.0.7+7 version: 0.0.8+8
environment: environment:
sdk: ^3.6.0 sdk: ^3.6.0