[READ-ONLY] Mirror of https://github.com/probablykasper/notifier. Android app for scheduling notifications
android app flutter notifications
0

Configure Feed

Select the types of activity you want to include in your feed.

Fixed multiple notifications appearing at the same time

Already scheduled notifications were not detected, and therefore notifications went on to be scheduled again and again

+23 -12
+23 -12
lib/models/list.dart
··· 154 154 155 155 List<PendingNotificationRequest> pendingNotifications = 156 156 await flutterLocalNotificationsPlugin.pendingNotificationRequests(); 157 - List<int> pendingNotificationItemIds = pendingNotifications.map((pendingNotification) { 158 - if (pendingNotification.id.toString().length > 1) 159 - return pendingNotification.id; 157 + List<String> pendingNotificationItemIds = pendingNotifications.map((pendingNotification) { 158 + String id = pendingNotification.id.toString(); 159 + if (id.length > 1) 160 + return id.substring(0, id.length - 1); 160 161 else 161 162 return null; 162 163 }).toList(); 164 + print('[notifier] ${pendingNotificationItemIds.length} items are currently scheduled'); 163 165 166 + print('========:::'); 167 + print(pendingNotificationItemIds); 164 168 _notificationItems.forEach((id, notificationItem) { 169 + print(':::------'); 170 + print(notificationItem['id']); 165 171 int next48h = DateTime.now().add(Duration(hours: 48)).millisecondsSinceEpoch; 166 172 if (!pendingNotificationItemIds.contains(notificationItem['id']) && 167 173 notificationItem['date'] < next48h && 168 174 notificationItem['disabled'] == false) { 169 - 170 175 // date to scheduel notification to now 171 176 DateTime date = DateTime.fromMillisecondsSinceEpoch(notificationItem['date']); 172 177 // date to scheduel notification to next time ··· 228 233 229 234 delete(String id) async { 230 235 _notificationItems.remove(id); 231 - List<PendingNotificationRequest> pendingNotifications = 236 + 237 + List pastPendingNotifications = 232 238 await flutterLocalNotificationsPlugin.pendingNotificationRequests(); 233 - print(pendingNotifications.length); 234 239 await cancelNotificationIfExists(id); 235 - List<PendingNotificationRequest> pendingNotifications2 = await flutterLocalNotificationsPlugin.pendingNotificationRequests(); 236 - print('[notifier] Cancelled ${pendingNotifications.length} scheduled notifications'); 240 + List currentPendingNotifications = 241 + await flutterLocalNotificationsPlugin.pendingNotificationRequests(); 242 + print( 243 + '[notifier] Cancelled ${pastPendingNotifications.length - currentPendingNotifications.length} scheduled notifications'); 244 + 237 245 await _save(); 238 246 print('[notifier] ListModel delete'); 239 247 notifyListeners(); ··· 243 251 notificationItem['id'] = id; 244 252 notificationItem['disabled'] = false; 245 253 _notificationItems[id] = notificationItem; 246 - List<PendingNotificationRequest> pendingNotifications = 254 + 255 + List pastPendingNotifications = 247 256 await flutterLocalNotificationsPlugin.pendingNotificationRequests(); 248 - print(pendingNotifications.length); 249 257 await cancelNotificationIfExists(id); 250 - List<PendingNotificationRequest> pendingNotifications2 = await flutterLocalNotificationsPlugin.pendingNotificationRequests(); 251 - print('[notifier] Cancelled ${pendingNotifications.length} scheduled notifications'); 258 + List currentPendingNotifications = 259 + await flutterLocalNotificationsPlugin.pendingNotificationRequests(); 260 + print( 261 + '[notifier] Cancelled ${pastPendingNotifications.length - currentPendingNotifications.length} scheduled notifications'); 262 + 252 263 await _save(); 253 264 await setNotifications(); 254 265 print('[notifier] ListModel update');