useLocalNotifications method
void
useLocalNotifications({
- DarwinInitializationSettings? iosSettings,
- AndroidInitializationSettings? androidSettings,
- LinuxInitializationSettings? linuxSettings,
- dynamic onDidReceiveLocalNotification(
- NotificationResponse details
- dynamic onDidReceiveBackgroundNotificationResponse(
- NotificationResponse details
Use local notifications
Implementation
void useLocalNotifications({
DarwinInitializationSettings? iosSettings,
AndroidInitializationSettings? androidSettings,
LinuxInitializationSettings? linuxSettings,
Function(NotificationResponse details)? onDidReceiveLocalNotification,
Function(NotificationResponse details)?
onDidReceiveBackgroundNotificationResponse,
}) {
_useLocalNotifications = true;
if (kIsWeb) {
return;
}
late InitializationSettings initializationSettings;
if (Platform.isAndroid) {
initializationSettings = InitializationSettings(
android: androidSettings ?? AndroidInitializationSettings('app_icon'),
);
}
if (Platform.isIOS || Platform.isMacOS) {
initializationSettings = InitializationSettings(
iOS: iosSettings ?? const DarwinInitializationSettings(),
);
}
if (Platform.isLinux) {
initializationSettings = InitializationSettings(
linux: linuxSettings ??
const LinuxInitializationSettings(
defaultActionName: 'Open notification'),
);
}
_initializationSettings = initializationSettings;
_onDidReceiveLocalNotification = onDidReceiveLocalNotification;
_onDidReceiveBackgroundNotificationResponse =
onDidReceiveBackgroundNotificationResponse;
}