Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

mobile: build notifee from source

ammarahm-ed047707dd3550
diff --git a/apps/mobile/app/services/background-sync.ts b/apps/mobile/app/services/background-sync.ts
index 64b4f2f25..db65c0e28 100644
--- a/apps/mobile/app/services/background-sync.ts
+++ b/apps/mobile/app/services/background-sync.ts
@@ -17,106 +17,107 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-import BackgroundFetch from "react-native-background-fetch";
-import { DatabaseLogger, db } from "../common/database";
-import { AppState, AppRegistry } from "react-native";
-import Notifications from "./notifications";
-import SettingsService from "./settings";
+// import BackgroundFetch from "react-native-background-fetch";
+// import { DatabaseLogger, db } from "../common/database";
+// import { AppState, AppRegistry } from "react-native";
+// import Notifications from "./notifications";
+// import SettingsService from "./settings";
-let backgroundFetchStarted = false;
-async function start() {
- if (backgroundFetchStarted) return;
- backgroundFetchStarted = true;
- // BackgroundFetch event handler.
- const onEvent = async (taskId: string) => {
- console.log("[BackgroundFetch] task: ", taskId, AppState.currentState);
- // Do your background work...
- await onBackgroundSyncStarted();
- // IMPORTANT: You must signal to the OS that your task is complete.
- BackgroundFetch.finish(taskId);
- };
+// let backgroundFetchStarted = false;
+// async function start() {
+// if (backgroundFetchStarted) return;
+// backgroundFetchStarted = true;
+// // BackgroundFetch event handler.
+// const onEvent = async (taskId: string) => {
+// console.log("[BackgroundFetch] task: ", taskId, AppState.currentState);
+// // Do your background work...
+// await onBackgroundSyncStarted();
+// // IMPORTANT: You must signal to the OS that your task is complete.
+// BackgroundFetch.finish(taskId);
+// };
- // Timeout callback is executed when your Task has exceeded its allowed running-time.
- // You must stop what you're doing immediately BackgroundFetch.finish(taskId)
- const onTimeout = async (taskId: string) => {
- console.warn("[BackgroundFetch] TIMEOUT: ", taskId);
- BackgroundFetch.finish(taskId);
- };
+// // Timeout callback is executed when your Task has exceeded its allowed running-time.
+// // You must stop what you're doing immediately BackgroundFetch.finish(taskId)
+// const onTimeout = async (taskId: string) => {
+// console.warn("[BackgroundFetch] TIMEOUT: ", taskId);
+// BackgroundFetch.finish(taskId);
+// };
- // Initialize BackgroundFetch only once when component mounts.
- const status = await BackgroundFetch.configure(
- {
- minimumFetchInterval: 15,
- enableHeadless: true,
- startOnBoot: true,
- stopOnTerminate: false,
- requiredNetworkType: BackgroundFetch.NETWORK_TYPE_ANY
- },
- onEvent,
- onTimeout
- );
- DatabaseLogger.info(`[BackgroundFetch] configure status: ${status}`);
- console.log(`[BackgroundFetch] configure status: ${status}`);
-}
+// // Initialize BackgroundFetch only once when component mounts.
+// const status = await BackgroundFetch.configure(
+// {
+// minimumFetchInterval: 15,
+// enableHeadless: true,
+// startOnBoot: true,
+// stopOnTerminate: false,
+// requiredNetworkType: BackgroundFetch.NETWORK_TYPE_ANY
+// },
+// onEvent,
+// onTimeout
+// );
+// DatabaseLogger.info(`[BackgroundFetch] configure status: ${status}`);
+// console.log(`[BackgroundFetch] configure status: ${status}`);
+// }
-const task = async (event: { taskId: string; timeout: boolean }) => {
- // Get task id from event {}:
- const taskId = event.taskId;
- const isTimeout = event.timeout; // <-- true when your background-time has expired.
- if (isTimeout) {
- console.log("[BackgroundFetch] Headless TIMEOUT:", taskId);
- BackgroundFetch.finish(taskId);
- return;
- }
- DatabaseLogger.info(
- "[BackgroundFetch HeadlessTask] start: " + taskId + AppState.currentState
- );
- await onBackgroundSyncStarted();
- BackgroundFetch.finish(taskId);
-};
+// const task = async (event: { taskId: string; timeout: boolean }) => {
+// // Get task id from event {}:
+// const taskId = event.taskId;
+// const isTimeout = event.timeout; // <-- true when your background-time has expired.
+// if (isTimeout) {
+// console.log("[BackgroundFetch] Headless TIMEOUT:", taskId);
+// BackgroundFetch.finish(taskId);
+// return;
+// }
+// DatabaseLogger.info(
+// "[BackgroundFetch HeadlessTask] start: " + taskId + AppState.currentState
+// );
+// await onBackgroundSyncStarted();
+// BackgroundFetch.finish(taskId);
+// };
-BackgroundFetch.registerHeadlessTask(task);
+// BackgroundFetch.registerHeadlessTask(task);
-async function onBackgroundSyncStarted() {
- try {
- DatabaseLogger.info("Background Sync" + "start");
- await db.init();
- const user = await db.user?.getUser();
- if (user) {
- await db.sync(true, false);
- }
- await Notifications.setupReminders();
- DatabaseLogger.info("Background Sync" + "end");
- } catch (e) {
- DatabaseLogger.error(e as Error);
- console.log("Background Sync Error", (e as Error).message);
- }
-}
+// async function onBackgroundSyncStarted() {
+// try {
+// DatabaseLogger.info("Background Sync" + "start");
+// await db.init();
+// const user = await db.user?.getUser();
+// if (user) {
+// await db.sync(true, false);
+// }
+// await Notifications.setupReminders();
+// DatabaseLogger.info("Background Sync" + "end");
+// } catch (e) {
+// DatabaseLogger.error(e as Error);
+// console.log("Background Sync Error", (e as Error).message);
+// }
+// }
-const onBoot = async () => {
- try {
- DatabaseLogger.info("BOOT TASK STARTED");
- await db.init();
- await Notifications.setupReminders();
- SettingsService.init();
- if (SettingsService.get().notifNotes) {
- Notifications.pinQuickNote(false);
- }
- DatabaseLogger.info("BOOT TASK COMPLETE");
- } catch (e) {
- console.log(e);
- }
-};
+// const onBoot = async () => {
+// try {
+// DatabaseLogger.info("BOOT TASK STARTED");
+// await db.init();
+// await Notifications.setupReminders();
+// SettingsService.init();
+// if (SettingsService.get().notifNotes) {
+// Notifications.pinQuickNote(false);
+// }
+// DatabaseLogger.info("BOOT TASK COMPLETE");
+// } catch (e) {
+// console.log(e);
+// }
+// };
-const registerHeadlessTask = () =>
- AppRegistry.registerHeadlessTask(
- "com.streetwriters.notesnook.BOOT_TASK",
- () => {
- return onBoot;
- }
- );
+// const registerHeadlessTask = () =>
+// AppRegistry.registerHeadlessTask(
+// "com.streetwriters.notesnook.BOOT_TASK",
+// () => {
+// return onBoot;
+// }
+// );
-export const BackgroundSync = {
- start,
- registerHeadlessTask
-};
+// export const BackgroundSync = {
+// start,
+// registerHeadlessTask
+// };
+export {};
diff --git a/apps/mobile/app/services/notifications.ts b/apps/mobile/app/services/notifications.ts
index cf5a6be08..36e9e0c88 100644
--- a/apps/mobile/app/services/notifications.ts
+++ b/apps/mobile/app/services/notifications.ts
@@ -516,6 +516,7 @@ async function checkAndRequestPermissions(
await notifee.openAlarmPermissionSettings();
}
permissionStatus = await notifee.getNotificationSettings();
+
if (
permissionStatus.authorizationStatus === AuthorizationStatus.AUTHORIZED &&
permissionStatus.android.alarm === 1
diff --git a/apps/mobile/native/android/build.gradle b/apps/mobile/native/android/build.gradle
index 2a2a86498..185c49561 100644
--- a/apps/mobile/native/android/build.gradle
+++ b/apps/mobile/native/android/build.gradle
@@ -69,8 +69,8 @@ allprojects {
maven { url 'https://www.jitpack.io' }
- maven {
- url("${project(':react-native-background-fetch').projectDir}/libs")
- }
+ // maven {
+ // url("${project(':react-native-background-fetch').projectDir}/libs")
+ // }
}
}
diff --git a/apps/mobile/native/package.json b/apps/mobile/native/package.json
index 5a5303c87..53d1cc008 100644
--- a/apps/mobile/native/package.json
+++ b/apps/mobile/native/package.json
@@ -52,12 +52,11 @@
"rn-fetch-blob": "^0.12.0",
"react-native-gzip":"1.0.0",
"@shopify/flash-list":"1.4.0",
- "@ammarahmed/notifee-react-native": "7.3.1",
+ "@ammarahmed/notifee-react-native": "7.4.3",
"react-native-modal-datetime-picker":"14.0.0",
"@react-native-community/datetimepicker":"6.6.0",
"react-native-date-picker": "4.2.6",
- "react-native-notification-sounds": "0.5.5",
- "react-native-background-fetch": "4.1.7"
+ "react-native-notification-sounds": "0.5.5"
},
"devDependencies": {
"@babel/core": "^7.12.9",
diff --git a/apps/mobile/package-lock.json b/apps/mobile/package-lock.json
index 749e24109..cce93de46 100644
--- a/apps/mobile/package-lock.json
+++ b/apps/mobile/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "@notesnook/mobile",
- "version": "2.4.2",
+ "version": "2.4.4",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@notesnook/mobile",
- "version": "2.4.2",
+ "version": "2.4.4",
"license": "GPL-3.0-or-later",
"workspaces": [
"native/",
@@ -60,7 +60,7 @@
"version": "1.0.0",
"license": "GPL-3.0-or-later",
"dependencies": {
- "@ammarahmed/notifee-react-native": "7.3.1",
+ "@ammarahmed/notifee-react-native": "7.4.3",
"@ammarahmed/react-native-sodium": "1.2.0",
"@callstack/repack": "^3.0.0",
"@react-native-clipboard/clipboard": "^1.9.0",
@@ -78,7 +78,6 @@
"react": "18.0.0",
"react-native": "0.69.7",
"react-native-background-actions": "^2.6.6",
- "react-native-background-fetch": "4.1.7",
"react-native-begin-background-task": "https://github.com/blockfirm/react-native-begin-background-task.git",
"react-native-bootsplash": "^4.1.4",
"react-native-config": "^1.4.6",
@@ -155,9 +154,9 @@
}
},
"node_modules/@ammarahmed/notifee-react-native": {
- "version": "7.3.1",
- "resolved": "https://registry.npmjs.org/@ammarahmed/notifee-react-native/-/notifee-react-native-7.3.1.tgz",
- "integrity": "sha512-kzBDw2NAt9kGD0CJ193JME4bS4uQolY+UubGiTnJwHfaLH7dFNju6RC15/u8tzG59ebDuCalkMLr+rAONtg2Rw==",
+ "version": "7.4.3",
+ "resolved": "https://registry.npmjs.org/@ammarahmed/notifee-react-native/-/notifee-react-native-7.4.3.tgz",
+ "integrity": "sha512-7jz91BZLxsz3v2nOPSnUf0ULa/k+KtkyX8zN2ijeluLHSQ5fjSd5jQ+u+4+Rcja0g0xQze7fpg26q6lA6F2j1g==",
"peerDependencies": {
"react-native": "*"
}
@@ -17977,11 +17976,6 @@
"react-native": ">=0.47.0"
}
},
- "node_modules/react-native-background-fetch": {
- "version": "4.1.7",
- "resolved": "https://registry.npmjs.org/react-native-background-fetch/-/react-native-background-fetch-4.1.7.tgz",
- "integrity": "sha512-dFY/AOZbEH+ldwZvq/UhhWI5+dyBYL1Xo5wqy6u5DLH+ef8jLIrwKQRmfLAWiP5BtZe6ktA55HM19X39qHoKEQ=="
- },
"node_modules/react-native-begin-background-task": {
"version": "0.1.0",
"resolved": "git+ssh://[email protected]/blockfirm/react-native-begin-background-task.git#c2aa793249db6cc6298a812905f955a99b864e78",
@@ -21516,9 +21510,9 @@
},
"dependencies": {
"@ammarahmed/notifee-react-native": {
- "version": "7.3.1",
- "resolved": "https://registry.npmjs.org/@ammarahmed/notifee-react-native/-/notifee-react-native-7.3.1.tgz",
- "integrity": "sha512-kzBDw2NAt9kGD0CJ193JME4bS4uQolY+UubGiTnJwHfaLH7dFNju6RC15/u8tzG59ebDuCalkMLr+rAONtg2Rw=="
+ "version": "7.4.3",
+ "resolved": "https://registry.npmjs.org/@ammarahmed/notifee-react-native/-/notifee-react-native-7.4.3.tgz",
+ "integrity": "sha512-7jz91BZLxsz3v2nOPSnUf0ULa/k+KtkyX8zN2ijeluLHSQ5fjSd5jQ+u+4+Rcja0g0xQze7fpg26q6lA6F2j1g=="
},
"@ammarahmed/react-native-sodium": {
"version": "1.2.0",
@@ -24316,7 +24310,7 @@
"@notesnook/mobile-native": {
"version": "file:native",
"requires": {
- "@ammarahmed/notifee-react-native": "7.3.1",
+ "@ammarahmed/notifee-react-native": "7.4.3",
"@ammarahmed/react-native-sodium": "1.2.0",
"@babel/core": "^7.12.9",
"@babel/eslint-parser": "^7.16.5",
@@ -24365,7 +24359,6 @@
"react-native": "0.69.7",
"react-native-actions-shortcuts": "^1.0.1",
"react-native-background-actions": "^2.6.6",
- "react-native-background-fetch": "4.1.7",
"react-native-begin-background-task": "https://github.com/blockfirm/react-native-begin-background-task.git",
"react-native-bootsplash": "^4.1.4",
"react-native-bundle-visualizer": "^3.1.1",
@@ -34859,11 +34852,6 @@
"eventemitter3": "^4.0.7"
}
},
- "react-native-background-fetch": {
- "version": "4.1.7",
- "resolved": "https://registry.npmjs.org/react-native-background-fetch/-/react-native-background-fetch-4.1.7.tgz",
- "integrity": "sha512-dFY/AOZbEH+ldwZvq/UhhWI5+dyBYL1Xo5wqy6u5DLH+ef8jLIrwKQRmfLAWiP5BtZe6ktA55HM19X39qHoKEQ=="
- },
"react-native-begin-background-task": {
"version": "git+ssh://[email protected]/blockfirm/react-native-begin-background-task.git#c2aa793249db6cc6298a812905f955a99b864e78",
"from": "react-native-begin-background-task@https://github.com/blockfirm/react-native-begin-background-task.git"
diff --git a/fastlane/metadata/android/en-US/changelogs/4196331.txt b/fastlane/metadata/android/en-US/changelogs/4196331.txt
new file mode 100644
index 000000000..c41a5dc8c
--- /dev/null
+++ b/fastlane/metadata/android/en-US/changelogs/4196331.txt
@@ -0,0 +1,3 @@
+- Bug fixes
+
+Thank you for using Notesnook!
\ No newline at end of file