Skip to content

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

mobile: fix crash on android 7.0 devices

ammarahm-ed92aab25da244
diff --git a/apps/mobile/app/hooks/use-shortcut-manager.ts b/apps/mobile/app/hooks/use-shortcut-manager.ts
index 5f03c1f0f..4d69ec7a9 100644
--- a/apps/mobile/app/hooks/use-shortcut-manager.ts
+++ b/apps/mobile/app/hooks/use-shortcut-manager.ts
@@ -22,9 +22,14 @@ import { NativeEventEmitter, NativeModule } from "react-native";
import { useRef } from "react";
import { Platform } from "react-native";
import { Linking } from "react-native";
+import deviceInfoModule from "react-native-device-info";
const ShortcutsEmitter = new NativeEventEmitter(
Shortcuts as unknown as NativeModule
);
+
+function isSupported() {
+ return Platform.OS !== "android" || deviceInfoModule.getApiLevelSync() > 25;
+}
const defaultShortcuts: ShortcutItem[] = [
{
type: "notesnook.action.newnote",
@@ -43,6 +48,7 @@ export const useShortcutManager = ({
const initialShortcutRecieved = useRef(false);
useEffect(() => {
+ if (!isSupported()) return;
Shortcuts.setShortcuts(shortcuts);
}, [shortcuts]);
@@ -52,6 +58,7 @@ export const useShortcutManager = ({
onShortcutPressed(defaultShortcuts[0]);
}
});
+ if (!isSupported()) return;
Shortcuts.getInitialShortcut().then((shortcut) => {
if (initialShortcutRecieved.current) return;
onShortcutPressed(shortcut);
diff --git a/apps/mobile/app/screens/editor/source.ts b/apps/mobile/app/screens/editor/source.ts
index f1c23a5a3..7d7371863 100644
--- a/apps/mobile/app/screens/editor/source.ts
+++ b/apps/mobile/app/screens/editor/source.ts
@@ -28,5 +28,5 @@ const EditorMobileSourceUrl =
* The url should be something like this: http://192.168.100.126:3000/index.html
*/
export const EDITOR_URI = __DEV__
- ? "http://192.168.10.3:3000/index.html"
+ ? EditorMobileSourceUrl
: EditorMobileSourceUrl;