Skip to content

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

mobile: fix background events (#1994)

Ammar Ahmed87a26504807e
diff --git a/apps/mobile/app/app.js b/apps/mobile/app/app.js
index 0068824e8..ccb5b3440 100644
--- a/apps/mobile/app/app.js
+++ b/apps/mobile/app/app.js
@@ -32,8 +32,6 @@ import { useUserStore } from "./stores/use-user-store";
import { View } from "react-native";
import { useState } from "react";
import NetInfo from "@react-native-community/netinfo";
-//import { BackgroundSync } from "./services/background-sync";
-Notifications.init();
NetInfo.configure({
reachabilityUrl: "https://notesnook.com",
reachabilityTest: (response) => {
diff --git a/apps/mobile/app/services/notifications.ts b/apps/mobile/app/services/notifications.ts
index 36e9e0c88..09c7c8d58 100644
--- a/apps/mobile/app/services/notifications.ts
+++ b/apps/mobile/app/services/notifications.ts
@@ -41,7 +41,6 @@ import { DDS } from "./device-detection";
import { eSendEvent } from "./event-manager";
import SettingsService from "./settings";
import { useSettingStore } from "../stores/use-setting-store";
-import ReminderNotify from "../components/sheets/reminder-notify";
import { sleep } from "../utils/time";
import { useRelationStore } from "../stores/use-relation-store";
import { useReminderStore } from "../stores/use-reminder-store";
@@ -107,6 +106,8 @@ const onEvent = async ({ type, detail }: Event) => {
if (notification?.data?.type === "reminder") {
const reminder = db.reminders?.reminder(notification.id?.split("_")[0]);
await sleep(1000);
+ const ReminderNotify =
+ require("../components/sheets/reminder-notify").default;
ReminderNotify.present(reminder);
}
@@ -451,6 +452,10 @@ async function displayNotification({
localOnly: true,
channelId: await getChannelId("default"),
autoCancel: false,
+ pressAction: {
+ id: "default",
+ mainComponent: "notesnook"
+ },
actions: actions?.map((action) => ({
pressAction: {
id: action
diff --git a/apps/mobile/native/android/app/build.gradle b/apps/mobile/native/android/app/build.gradle
index a51efc12a..aaa1ca01b 100644
--- a/apps/mobile/native/android/app/build.gradle
+++ b/apps/mobile/native/android/app/build.gradle
@@ -288,8 +288,9 @@ android {
if (fdroidBuild()) {
output.versionCodeOverride =
defaultConfig.versionCode * 5 + versionCodes.get(abi)
- println("Version code: ${output.versionCodeOverride} for abi ${versionCodes.get(abi)}");
+ println("Fdroid Version code: ${output.versionCodeOverride} for abi ${versionCodes.get(abi)}");
} else {
+ println("Version code: ${output.versionCodeOverride} for abi ${versionCodes.get(abi)}");
output.versionCodeOverride =
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
}
diff --git a/apps/mobile/native/index.js b/apps/mobile/native/index.js
index 3728f9124..8713a1370 100644
--- a/apps/mobile/native/index.js
+++ b/apps/mobile/native/index.js
@@ -6,7 +6,8 @@ import { AppRegistry, LogBox, Platform, UIManager } from 'react-native';
import Config from 'react-native-config';
import { SafeAreaProvider } from 'react-native-safe-area-context';
import appJson from './app.json';
-//import {BackgroundSync} from '../app/services/background-sync';
+import Notifications from "../app/services/notifications";
+Notifications.init();
const appName = appJson.name;
if (Config.isTesting) {
@@ -21,7 +22,6 @@ if (__DEV__) {
}
let NotesnookShare;
-//BackgroundSync.registerHeadlessTask();
let QuickNoteIOS;
const AppProvider = () => {
diff --git a/apps/mobile/native/ios/Notesnook.xcodeproj/project.pbxproj b/apps/mobile/native/ios/Notesnook.xcodeproj/project.pbxproj
index b1a793c72..75385fdfe 100644
--- a/apps/mobile/native/ios/Notesnook.xcodeproj/project.pbxproj
+++ b/apps/mobile/native/ios/Notesnook.xcodeproj/project.pbxproj
@@ -29,7 +29,6 @@
65AA857E25E6DDEC00772A01 /* NotesWidget.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65AA857D25E6DDEC00772A01 /* NotesWidget.swift */; };
65AA858025E6DDEE00772A01 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 65AA857F25E6DDEE00772A01 /* Assets.xcassets */; };
65AA858425E6DDEE00772A01 /* NotesWidgetExtension.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = 65AA857725E6DDEC00772A01 /* NotesWidgetExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
- 65B450AD2976AF0C00EA090B /* RNBackgroundFetch+AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 65B450AC2976AF0B00EA090B /* RNBackgroundFetch+AppDelegate.m */; };
65B5014425A672B200E2D264 /* ShareViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 65B5014325A672B200E2D264 /* ShareViewController.m */; };
65B5014725A672B200E2D264 /* MainInterface.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 65B5014525A672B200E2D264 /* MainInterface.storyboard */; };
65B5014B25A672B200E2D264 /* Make Note.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = 65B5014025A672B200E2D264 /* Make Note.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
@@ -123,7 +122,6 @@
65AA857D25E6DDEC00772A01 /* NotesWidget.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotesWidget.swift; sourceTree = "<group>"; };
65AA857F25E6DDEE00772A01 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
65AA858125E6DDEE00772A01 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
- 65B450AC2976AF0B00EA090B /* RNBackgroundFetch+AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "RNBackgroundFetch+AppDelegate.m"; path = "../../node_modules/react-native-background-fetch/ios/RNBackgroundFetch/RNBackgroundFetch+AppDelegate.m"; sourceTree = "<group>"; };
65B5014025A672B200E2D264 /* Make Note.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = "Make Note.appex"; sourceTree = BUILT_PRODUCTS_DIR; };
65B5014325A672B200E2D264 /* ShareViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ShareViewController.m; sourceTree = "<group>"; };
65B5014625A672B200E2D264 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/MainInterface.storyboard; sourceTree = "<group>"; };
@@ -223,7 +221,6 @@
13B07FAE1A68108700A75B9A /* Notesnook */ = {
isa = PBXGroup;
children = (
- 65B450AC2976AF0B00EA090B /* RNBackgroundFetch+AppDelegate.m */,
6593E4A2281C345400492C50 /* AppDelegate.mm */,
6529A13D279BC4C70048D4A8 /* BootSplash.storyboard */,
659BE46625E11A5100E05671 /* notesnook-text.png */,
@@ -944,7 +941,6 @@
65E0340B257B9FF100793428 /* File.swift in Sources */,
6593E4A3281C345400492C50 /* AppDelegate.mm in Sources */,
13B07FC11A68108700A75B9A /* main.m in Sources */,
- 65B450AD2976AF0C00EA090B /* RNBackgroundFetch+AppDelegate.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
diff --git a/apps/mobile/native/ios/Notesnook/AppDelegate.mm b/apps/mobile/native/ios/Notesnook/AppDelegate.mm
index 623c30992..e74372e52 100644
--- a/apps/mobile/native/ios/Notesnook/AppDelegate.mm
+++ b/apps/mobile/native/ios/Notesnook/AppDelegate.mm
@@ -7,7 +7,7 @@
#import <React/RCTAppSetupUtils.h>
#import <React/RCTLinkingManager.h>
#import "RNShortcuts.h"
-#import <TSBackgroundFetch/TSBackgroundFetch.h>
+//#import <TSBackgroundFetch/TSBackgroundFetch.h>
#if RCT_NEW_ARCH_ENABLED
#import <React/CoreModulesPlugins.h>
@@ -63,7 +63,7 @@ RCTBridge *bridge;
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
self.window.rootViewController = rootViewController;
[self.window makeKeyAndVisible];
- [[TSBackgroundFetch sharedInstance] didFinishLaunching];
+ //[[TSBackgroundFetch sharedInstance] didFinishLaunching];
return YES;
}
diff --git a/apps/mobile/native/ios/Podfile.lock b/apps/mobile/native/ios/Podfile.lock
index 7e6ece667..750b2c710 100644
--- a/apps/mobile/native/ios/Podfile.lock
+++ b/apps/mobile/native/ios/Podfile.lock
@@ -345,8 +345,6 @@ PODS:
- React-Core
- rn-fetch-blob (0.12.0):
- React-Core
- - RNBackgroundFetch (4.1.7):
- - React-Core
- RNBootSplash (4.3.2):
- React-Core
- RNCCheckbox (0.5.12):
@@ -371,10 +369,10 @@ PODS:
- React-Core
- RNKeychain (4.0.5):
- React
- - RNNotifee (7.3.1):
+ - RNNotifee (7.4.3):
- React-Core
- - RNNotifee/NotifeeCore (= 7.3.1)
- - RNNotifee/NotifeeCore (7.3.1):
+ - RNNotifee/NotifeeCore (= 7.4.3)
+ - RNNotifee/NotifeeCore (7.4.3):
- React-Core
- RNPrivacySnapshot (1.0.0):
- React-Core
@@ -483,7 +481,6 @@ DEPENDENCIES:
- ReactCommon/turbomodule/core (from `../../node_modules/react-native/ReactCommon`)
- rn-extensions-share (from `../../node_modules/rn-extensions-share`)
- rn-fetch-blob (from `../../node_modules/rn-fetch-blob`)
- - RNBackgroundFetch (from `../../node_modules/react-native-background-fetch`)
- RNBootSplash (from `../../node_modules/react-native-bootsplash`)
- "RNCCheckbox (from `../../node_modules/@react-native-community/checkbox`)"
- "RNCClipboard (from `../../node_modules/@react-native-clipboard/clipboard`)"
@@ -625,8 +622,6 @@ EXTERNAL SOURCES:
:path: "../../node_modules/rn-extensions-share"
rn-fetch-blob:
:path: "../../node_modules/rn-fetch-blob"
- RNBackgroundFetch:
- :path: "../../node_modules/react-native-background-fetch"
RNBootSplash:
:path: "../../node_modules/react-native-bootsplash"
RNCCheckbox:
@@ -741,7 +736,6 @@ SPEC CHECKSUMS:
ReactCommon: 1e783348b9aa73ae68236271df972ba898560a95
rn-extensions-share: 3f0ecce20dfbca1f0358deb4ebfb9ee121a6d92a
rn-fetch-blob: f065bb7ab7fb48dd002629f8bdcb0336602d3cba
- RNBackgroundFetch: 13fbe7b23d4a082eac8caa7b08c5bcbeabd92f79
RNBootSplash: 5f346163977573d6b2aeba1b25df9d2245c0d73c
RNCCheckbox: ed1b4ca295475b41e7251ebae046360a703b6eb5
RNCClipboard: 2834e1c4af68697089cdd455ee4a4cdd198fa7dd
@@ -754,7 +748,7 @@ SPEC CHECKSUMS:
RNGestureHandler: b7a872907ee289ada902127f2554fa1d2c076122
RNIap: d248609d1b8937e63bd904e865c318e9b1457eff
RNKeychain: 840f8e6f13be0576202aefcdffd26a4f54bfe7b5
- RNNotifee: 2fab820e17613db15a1f836053ee3b87af7e96b9
+ RNNotifee: 5dfb0c5783ddb3da47b39e75d06cc7e748d6ca39
RNPrivacySnapshot: 8eaf571478a353f2e5184f5c803164f22428b023
RNReanimated: f1b109fb8341505ace9d7d2eedd150da1686716b
RNScreens: 34cc502acf1b916c582c60003dc3089fa01dc66d