fix: Request notification permissions on iOS before getToken

This commit is contained in:
Krille 2025-02-19 16:52:13 +01:00
commit 69711506ea
No known key found for this signature in database
GPG key ID: E067ECD60F1A0652

View file

@ -72,6 +72,9 @@ class BackgroundPush {
void _init() async { void _init() async {
try { try {
if (PlatformInfos.isIOS) {
await firebase?.requestPermission();
}
await _flutterLocalNotificationsPlugin.initialize( await _flutterLocalNotificationsPlugin.initialize(
const InitializationSettings( const InitializationSettings(
android: AndroidInitializationSettings('notifications_icon'), android: AndroidInitializationSettings('notifications_icon'),
@ -147,9 +150,7 @@ class BackgroundPush {
Set<String?>? oldTokens, Set<String?>? oldTokens,
bool useDeviceSpecificAppId = false, bool useDeviceSpecificAppId = false,
}) async { }) async {
if (PlatformInfos.isIOS) { if (PlatformInfos.isAndroid) {
await firebase?.requestPermission();
} else if (PlatformInfos.isAndroid) {
_flutterLocalNotificationsPlugin _flutterLocalNotificationsPlugin
.resolvePlatformSpecificImplementation< .resolvePlatformSpecificImplementation<
AndroidFlutterLocalNotificationsPlugin>() AndroidFlutterLocalNotificationsPlugin>()