A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
mobile: fix notification triggers on ios
ammarahm-ed80f5ecb27683
diff --git a/apps/mobile/app/services/notifications.ts b/apps/mobile/app/services/notifications.tsindex 48f0e8a6c..73e5cb929 100644--- a/apps/mobile/app/services/notifications.ts+++ b/apps/mobile/app/services/notifications.ts@@ -215,7 +215,7 @@ async function setupIOSCategories() {{id: "REMINDER_SNOOZE",foreground: false,- title: "Remind in 10 min",+ title: `Remind in ${reminderTime} min`,authenticationRequired: false}]@@ -259,6 +259,7 @@ async function scheduleNotification(await remove(reminder.id);if (reminder.disabled) return;const triggers = await getTriggers(reminder);+ console.log(triggers);if (!triggers && reminder.mode === "permanent") {displayNotification({id: reminder.id,@@ -300,7 +301,7 @@ async function scheduleNotification(}});}-+ console.log(trigger);await notifee.createTriggerNotification({id: trigger.id,@@ -328,7 +329,11 @@ async function scheduleNotification(}},ios: {- interruptionLevel: priority === "silent" ? "passive" : "active",+ interruptionLevel: "active",+ critical:+ reminder.priority === "silent" || reminder.priority === "urgent"+ ? false+ : true,categoryId:reminder.mode === "repeat" ? "REMINDER_RECURRING" : "REMINDER",...iosProperties@@ -516,8 +521,10 @@ async function getTriggers(.hour(relativeTime.hour()).minute(relativeTime.minute());if (timestamp.isBefore(dayjs())) {- timestamp = timestamp.add(1, "day");- timestamp.second(0);+ do {+ timestamp = timestamp.add(1, "day");+ timestamp.second(0);+ } while (timestamp.isBefore(dayjs()));}triggers.push({timestamp: timestamp.valueOf() as number,@@ -550,12 +557,16 @@ async function getTriggers(}for (const day of selectedDays) {- const timestamp = dayjs()+ let timestamp = dayjs().day(day).hour(relativeTime.hour()).minute(relativeTime.minute());- if (timestamp.isBefore(dayjs())) continue;+ if (timestamp.isBefore(dayjs())) {+ do {+ timestamp = timestamp.add(1, "week");+ } while (timestamp.isBefore(dayjs()));+ }triggers.push({timestamp: timestamp.toDate().getTime() as number,@@ -587,13 +598,16 @@ async function getTriggers(}if (Platform.OS === "ios") {for (const day of selectedDays) {- const timestamp = dayjs()+ let timestamp = dayjs().date(day).hour(relativeTime.hour()).minute(relativeTime.minute());- if (timestamp.isBefore(dayjs())) continue;-+ if (timestamp.isBefore(dayjs())) {+ do {+ timestamp = timestamp.add(1, "month");+ } while (timestamp.isBefore(dayjs()));+ }triggers.push({timestamp: timestamp.toDate().getTime() as number,type: TriggerType.TIMESTAMP,@@ -674,7 +688,6 @@ function get(): Promise<DisplayedNotification[]> {}function init() {- if (Platform.OS === "ios") return;notifee.onBackgroundEvent(onEvent);notifee.onForegroundEvent(onEvent);}diff --git a/apps/mobile/native/ios/Notesnook/Info.plist b/apps/mobile/native/ios/Notesnook/Info.plistindex 8897b8cc5..a956ee851 100644--- a/apps/mobile/native/ios/Notesnook/Info.plist+++ b/apps/mobile/native/ios/Notesnook/Info.plist@@ -100,6 +100,7 @@</dict><key>UIBackgroundModes</key><array>+ <string>fetch</string><string>processing</string></array><key>UIFileSharingEnabled</key>diff --git a/apps/mobile/native/ios/Podfile.lock b/apps/mobile/native/ios/Podfile.lockindex 3c2fad848..f5dbb7af9 100644--- a/apps/mobile/native/ios/Podfile.lock+++ b/apps/mobile/native/ios/Podfile.lock@@ -238,6 +238,8 @@ PODS:- react-native-config/App (= 1.4.11)- react-native-config/App (1.4.11):- React-Core+ - react-native-date-picker (4.2.6):+ - React-Core- react-native-document-picker (7.1.3):- React-Core- react-native-fingerprint-scanner (5.0.0):@@ -450,6 +452,7 @@ DEPENDENCIES:- react-native-background-actions (from `../../node_modules/react-native-background-actions`)- react-native-begin-background-task (from `../../node_modules/react-native-begin-background-task`)- react-native-config (from `../../node_modules/react-native-config`)+ - react-native-date-picker (from `../../node_modules/react-native-date-picker`)- react-native-document-picker (from `../../node_modules/react-native-document-picker`)- react-native-fingerprint-scanner (from `../../node_modules/react-native-fingerprint-scanner`)- react-native-get-random-values (from `../../node_modules/react-native-get-random-values`)@@ -561,6 +564,8 @@ EXTERNAL SOURCES::path: "../../node_modules/react-native-begin-background-task"react-native-config::path: "../../node_modules/react-native-config"+ react-native-date-picker:+ :path: "../../node_modules/react-native-date-picker"react-native-document-picker::path: "../../node_modules/react-native-document-picker"react-native-fingerprint-scanner:@@ -702,6 +707,7 @@ SPEC CHECKSUMS:react-native-background-actions: 2c251c986f23347f9c1722f05fd296938f60edb1react-native-begin-background-task: 3b889e07458afc5822a7277cf9cbc7cd077e39eereact-native-config: bcafda5b4c51491ee1b0e1d0c4e3905bc7b56c1b+ react-native-date-picker: 93e43b3084cea595b4d68b1405d6d99849663bd6react-native-document-picker: ec07866a30707f23660c0f3ae591d669d3e89096react-native-fingerprint-scanner: be63e626b31fb951780a5fac5328b065a61a3d6ereact-native-get-random-values: a6ea6a8a65dc93e96e24a11105b1a9c8cfe1d72a