Test Notification

main
Kai Mannweiler 2023-02-25 14:58:10 +01:00
parent 36abb7da36
commit 09d5e51377
3 changed files with 26 additions and 2 deletions

View File

@ -30,6 +30,7 @@ android {
ndkVersion flutter.ndkVersion
compileOptions {
coreLibraryDesugaringEnabled true
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

View File

@ -68,7 +68,7 @@ class ScannerPageState extends State<ScannerPage> {
textStyle: const TextStyle(fontSize: 20)),
onPressed: () {
loadSettingsFromLocalJSON();
NotificationService().setAllNotifications();
NotificationService().showNotification();
},
child: const Text('Read JSON'),
)

View File

@ -18,7 +18,7 @@ class NotificationService {
Future<void> initNotification() async {
// Android initialization
const AndroidInitializationSettings initializationSettingsAndroid =
AndroidInitializationSettings('@mipmap/ic_launcher');
AndroidInitializationSettings('mipmap/ic_launcher');
// ios initialization
const DarwinInitializationSettings initializationSettingsIOS =
@ -38,6 +38,29 @@ class NotificationService {
print(initialized);
}
Future<void> showNotification() async {
await flutterLocalNotificationsPlugin.show(
0,
'test',
'test',
//schedule the notification to show after 2 seconds.
const NotificationDetails(
// Android details
android: AndroidNotificationDetails('main_channel', 'Main Channel',
channelDescription: "ashwin",
importance: Importance.max,
priority: Priority.max),
// iOS details
iOS: DarwinNotificationDetails(
sound: 'default.wav',
presentAlert: true,
presentBadge: true,
presentSound: true,
),
),
);
}
Future<void> setAllNotifications() async {
List<TZDateTime> moodDates = await getDatesforMood();
List<TZDateTime> sleepDates = await getDatesforSleep();