diff --git a/src/views/Chores/LocalNotificationScheduler.js b/src/views/Chores/LocalNotificationScheduler.js index 12e6b89..7ca1968 100644 --- a/src/views/Chores/LocalNotificationScheduler.js +++ b/src/views/Chores/LocalNotificationScheduler.js @@ -3,6 +3,8 @@ import { LocalNotifications } from '@capacitor/local-notifications' import { Preferences } from '@capacitor/preferences' import murmurhash from 'murmurhash' +const MAX_LOCAL_NOTIFICATIONS = 64 + const getNotificationPreferences = async () => { const ret = await Preferences.get({ key: 'notificationPreferences' }) return JSON.parse(ret.value) @@ -206,6 +208,13 @@ const scheduleChoreNotification = async ( continue } } + // sort from soonest to latest: + notifications.sort((a, b) => a.schedule.at - b.schedule.at) + + // cap it for 64 notifications for Android: + if (notifications.length > MAX_LOCAL_NOTIFICATIONS) { + notifications.splice(MAX_LOCAL_NOTIFICATIONS) + } LocalNotifications.schedule({ notifications,