41 lines
1.7 KiB
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 notificationId = 1;
|
|
const NotificationDetails notificationDetails =
|
|
NotificationDetails(android: androidNotificationDetails);
|
|
|
|
await FlutterLocalNotificationsPlugin().show(
|
|
notificationId, 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 notificationId = 1;
|
|
|
|
NotificationDetails platformChannelSpecifics =
|
|
NotificationDetails(iOS: iOSPlatformChannelSpecifics);
|
|
|
|
await FlutterLocalNotificationsPlugin().show(
|
|
notificationId, title, value, platformChannelSpecifics,
|
|
payload: 'Not present');
|
|
}
|