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,26 +55,32 @@ class Startup {
FlutterLocalNotificationsPlugin(); FlutterLocalNotificationsPlugin();
// Get permission to show notifications // Get permission to show notifications
flutterLocalNotificationsPlugin if (Platform.isAndroid) {
.resolvePlatformSpecificImplementation< await flutterLocalNotificationsPlugin
.resolvePlatformSpecificImplementation<
AndroidFlutterLocalNotificationsPlugin>()! AndroidFlutterLocalNotificationsPlugin>()!
.requestPermission(); .requestPermission();
await flutterLocalNotificationsPlugin }
.resolvePlatformSpecificImplementation< else if (Platform.isIOS) {
IOSFlutterLocalNotificationsPlugin>() await flutterLocalNotificationsPlugin
?.requestPermissions( .resolvePlatformSpecificImplementation<
alert: false, IOSFlutterLocalNotificationsPlugin>()
badge: true, ?.requestPermissions(
sound: true, alert: false,
); badge: true,
await flutterLocalNotificationsPlugin sound: true,
.resolvePlatformSpecificImplementation< );
MacOSFlutterLocalNotificationsPlugin>() }
?.requestPermissions( else if (Platform.isMacOS) {
alert: false, await flutterLocalNotificationsPlugin
badge: true, .resolvePlatformSpecificImplementation<
sound: true, MacOSFlutterLocalNotificationsPlugin>()
); ?.requestPermissions(
alert: false,
badge: true,
sound: true,
);
}
// Platform specific settings // Platform specific settings
final DarwinInitializationSettings initializationSettingsDarwin = final DarwinInitializationSettings initializationSettingsDarwin =