Notifications are working properly on Android but not working at all on iOS (tried on emulator).
I have the code in the main page and the notification doesn’t show.
Please note that I already made changes on AppDelegate.swift file.
FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin = FlutterLocalNotificationsPlugin();
flutterLocalNotificationsPlugin
.resolvePlatformSpecificImplementation<
AndroidFlutterLocalNotificationsPlugin>()!
.requestPermission();
const AndroidInitializationSettings initializationSettingsAndroid = AndroidInitializationSettings('icon');
final DarwinInitializationSettings initializationSettingsDarwin =
DarwinInitializationSettings(
requestSoundPermission: true,
requestBadgePermission: true,
requestAlertPermission: true,
onDidReceiveLocalNotification: onDidReceiveLocalNotification);
final InitializationSettings initializationSettings =
InitializationSettings(
android: initializationSettingsAndroid,
iOS: initializationSettingsDarwin,
macOS: initializationSettingsDarwin);
await flutterLocalNotificationsPlugin.initialize(initializationSettings, onDidReceiveNotificationResponse: onDidReceiveNotificationResponse);
const AndroidNotificationDetails androidNotificationDetails =
AndroidNotificationDetails('can1', 'Channel 1',
channelDescription: "Desc here",
importance: Importance.max,
priority: Priority.high,
ticker: 'ticker');
const NotificationDetails notificationDetails =
NotificationDetails(android: androidNotificationDetails);
await flutterLocalNotificationsPlugin.show(
0, 'Notification is working!', 'Hello world', notificationDetails, payload: 'item x');
2
Answers
It’s happened to me before but different issue (updates problems) on android and finally found that’s
Notification doesnt work in ios emulator, you need to use real device