didvan-app/lib/services/notification/lc/show_notification_handler.dart

41 lines
1.7 KiB
Dart

import 'package:flutter_local_notifications/flutter_local_notifications.dart';
void showNotificationAndroid(String title, String value) async {
const AndroidNotificationDetails androidNotificationDetails =
AndroidNotificationDetails('channel_id', 'Channel Name',
channelDescription: 'Channel Description',
importance: Importance.max,
priority: Priority.high,
ticker: 'ticker');
int notification_id = 1;
const NotificationDetails notificationDetails =
NotificationDetails(android: androidNotificationDetails);
await FlutterLocalNotificationsPlugin().show(
notification_id, title, value, notificationDetails,
payload: 'Not present');
}
void showNotificationIos(String title, String value) async {
DarwinNotificationDetails iOSPlatformChannelSpecifics = DarwinNotificationDetails(
presentAlert: true,
// Present an alert when the notification is displayed and the application is in the foreground (only from iOS 10 onwards)
presentBadge: true,
// Present the badge number when the notification is displayed and the application is in the foreground (only from iOS 10 onwards)
presentSound: true,
// Play a sound when the notification is displayed and the application is in the foreground (only from iOS 10 onwards)
subtitle: title,
//Secondary description (only from iOS 10 onwards)
threadIdentifier: value);
int notification_id = 1;
NotificationDetails platformChannelSpecifics =
NotificationDetails(iOS: iOSPlatformChannelSpecifics);
await FlutterLocalNotificationsPlugin().show(
notification_id, title, value, platformChannelSpecifics,
payload: 'Not present');
}