Skip to content

Commit

Permalink
fixed notifications caused by weird bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Benimautner committed Apr 28, 2022
1 parent 32cdfea commit aef7ce3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
9 changes: 4 additions & 5 deletions lib/global.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,14 @@ class VikunjaGlobalState extends State<VikunjaGlobal> {
new LabelTaskBulkAPIService(client);

var androidSpecificsDueDate = notifs.AndroidNotificationDetails(
"Vikunja Due",
"Vikunja1",
"Due Date Notifications",
channelDescription: "description",
icon: 'ic_launcher_foreground',
importance: notifs.Importance.high
);
var androidSpecificsReminders = notifs.AndroidNotificationDetails(
"Vikunja Reminders",
"Vikunja2",
"Reminder Notifications",
channelDescription: "description",
icon: 'ic_launcher_foreground',
Expand All @@ -97,12 +97,12 @@ class VikunjaGlobalState extends State<VikunjaGlobal> {
super.initState();
_loadCurrentUser();
tz.initializeTimeZones();
notificationInitializer();
iOSSpecifics = notifs.IOSNotificationDetails();
platformChannelSpecificsDueDate = notifs.NotificationDetails(
android: androidSpecificsDueDate, iOS: iOSSpecifics);
platformChannelSpecificsReminders = notifs.NotificationDetails(
android: androidSpecificsReminders, iOS: iOSSpecifics);
notificationInitializer();
}

void changeUser(User newUser, {String token, String base}) async {
Expand Down Expand Up @@ -134,12 +134,11 @@ class VikunjaGlobalState extends State<VikunjaGlobal> {
notifLaunch = await notificationsPlugin.getNotificationAppLaunchDetails();
await notifications.initNotifications(notificationsPlugin);
requestIOSPermissions(notificationsPlugin);

}

void scheduleDueNotifications() {
notificationsPlugin.cancelAll().then((value) {
taskService.getAll().then((value) =>
taskService.getByOptions(taskServiceOptions).then((value) =>
value.forEach((task) {
if(task.reminderDates != null)
task.reminderDates.forEach((reminder) {
Expand Down
3 changes: 1 addition & 2 deletions lib/managers/notifications.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class NotificationClass{

Future<void> initNotifications(notifs.FlutterLocalNotificationsPlugin notifsPlugin) async {
var initializationSettingsAndroid =
notifs.AndroidInitializationSettings('vikunja_logo');
notifs.AndroidInitializationSettings('ic_launcher_foreground');
var initializationSettingsIOS = notifs.IOSInitializationSettings(
requestAlertPermission: false,
requestBadgePermission: false,
Expand Down Expand Up @@ -55,7 +55,6 @@ Future<void> scheduleNotification(String title, String description,
id = Random().nextInt(1000000);
final String currentTimeZone = await FlutterNativeTimezone.getLocalTimezone();
tz.TZDateTime time = tz.TZDateTime.from(scheduledTime,tz.getLocation(currentTimeZone));
//time.add(Duration(hours: -2));
await notifsPlugin.zonedSchedule(id, title, description,
time, platformChannelSpecifics, androidAllowWhileIdle: true, uiLocalNotificationDateInterpretation: notifs.UILocalNotificationDateInterpretation.wallClockTime); // This literally schedules the notification
}
Expand Down

0 comments on commit aef7ce3

Please sign in to comment.