iOS notification permission fix

This commit is contained in:
Tihanyi Marcell 2023-06-12 20:09:48 +02:00
parent 131454b99d
commit f78a542be2

View File

@ -1,3 +1,5 @@
import 'dart:io';
import 'package:background_fetch/background_fetch.dart'; import 'package:background_fetch/background_fetch.dart';
import 'package:filcnaplo/api/providers/user_provider.dart'; import 'package:filcnaplo/api/providers/user_provider.dart';
import 'package:filcnaplo/api/providers/database_provider.dart'; import 'package:filcnaplo/api/providers/database_provider.dart';
@ -53,10 +55,13 @@ class Startup {
FlutterLocalNotificationsPlugin(); FlutterLocalNotificationsPlugin();
// Get permission to show notifications // Get permission to show notifications
flutterLocalNotificationsPlugin if (Platform.isAndroid) {
await flutterLocalNotificationsPlugin
.resolvePlatformSpecificImplementation< .resolvePlatformSpecificImplementation<
AndroidFlutterLocalNotificationsPlugin>()! AndroidFlutterLocalNotificationsPlugin>()!
.requestPermission(); .requestPermission();
}
else if (Platform.isIOS) {
await flutterLocalNotificationsPlugin await flutterLocalNotificationsPlugin
.resolvePlatformSpecificImplementation< .resolvePlatformSpecificImplementation<
IOSFlutterLocalNotificationsPlugin>() IOSFlutterLocalNotificationsPlugin>()
@ -65,6 +70,8 @@ class Startup {
badge: true, badge: true,
sound: true, sound: true,
); );
}
else if (Platform.isMacOS) {
await flutterLocalNotificationsPlugin await flutterLocalNotificationsPlugin
.resolvePlatformSpecificImplementation< .resolvePlatformSpecificImplementation<
MacOSFlutterLocalNotificationsPlugin>() MacOSFlutterLocalNotificationsPlugin>()
@ -73,6 +80,7 @@ class Startup {
badge: true, badge: true,
sound: true, sound: true,
); );
}
// Platform specific settings // Platform specific settings
final DarwinInitializationSettings initializationSettingsDarwin = final DarwinInitializationSettings initializationSettingsDarwin =