diff --git a/apps/mobile/android/app/src/main/java/com/streetwriters/notesnook/BootTaskService.java b/apps/mobile/android/app/src/main/java/com/streetwriters/notesnook/BootTaskService.java index cc5f904b8..06c1fcd92 100644 --- a/apps/mobile/android/app/src/main/java/com/streetwriters/notesnook/BootTaskService.java +++ b/apps/mobile/android/app/src/main/java/com/streetwriters/notesnook/BootTaskService.java @@ -39,28 +39,32 @@ public class BootTaskService extends HeadlessJsTaskService { @Override public int onStartCommand(Intent intent, int flags, int startId) { - if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) { - NotificationChannel channel = new NotificationChannel("com.streetwriters.notesnook", - "Default", - NotificationManager.IMPORTANCE_DEFAULT); + try { + if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) { + NotificationChannel channel = new NotificationChannel("com.streetwriters.notesnook", + "Default", + NotificationManager.IMPORTANCE_DEFAULT); + + ((NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE)).createNotificationChannel(channel); + notification = new NotificationCompat.Builder(this, channel.getId()) + .setContentTitle("Sync on boot") + .setContentText("") + .setSmallIcon(R.drawable.ic_stat_name) + .build(); + if (android.os.Build.VERSION.SDK_INT >= 34) { + this.startForeground( + 1, + notification, + ServiceInfo.FOREGROUND_SERVICE_TYPE_SPECIAL_USE); + } else { + this.startForeground( + 1, + notification); + } - ((NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE)).createNotificationChannel(channel); - notification = new NotificationCompat.Builder(this, channel.getId()) - .setContentTitle("Sync on boot") - .setContentText("") - .setSmallIcon(R.drawable.ic_stat_name) - .build(); - if (android.os.Build.VERSION.SDK_INT >= 34) { - this.startForeground( - 1, - notification, - ServiceInfo.FOREGROUND_SERVICE_TYPE_SPECIAL_USE); - } else { - this.startForeground( - 1, - notification); } - + } catch (Exception ignored) { + stopSelf(startId); } return super.onStartCommand(intent, flags, startId); diff --git a/apps/mobile/package-lock.json b/apps/mobile/package-lock.json index 98dec652e..da815f942 100644 --- a/apps/mobile/package-lock.json +++ b/apps/mobile/package-lock.json @@ -10,8 +10,8 @@ "hasInstallScript": true, "license": "GPL-3.0-or-later", "dependencies": { - "@ammarahmed/notifee-react-native": "^7.4.11", - "@ammarahmed/react-native-background-fetch": "^4.2.2", + "@ammarahmed/notifee-react-native": "^7.4.12", + "@ammarahmed/react-native-background-fetch": "^4.2.3", "@ammarahmed/react-native-eventsource": "1.1.0", "@ammarahmed/react-native-fingerprint-scanner": "^5.0.1", "@ammarahmed/react-native-share-extension": "^2.9.5", @@ -490,18 +490,18 @@ } }, "node_modules/@ammarahmed/notifee-react-native": { - "version": "7.4.11", - "resolved": "https://registry.npmjs.org/@ammarahmed/notifee-react-native/-/notifee-react-native-7.4.11.tgz", - "integrity": "sha512-9zKhONgir2FN/sMj/rsKAhDwfxadDuxB6LJILKxpGwzqvcIuG70oCKWmBBG9LJJpSfcVpNTdxBoH9RtNZTZSsQ==", + "version": "7.4.12", + "resolved": "https://registry.npmjs.org/@ammarahmed/notifee-react-native/-/notifee-react-native-7.4.12.tgz", + "integrity": "sha512-rZPtHdWZ3PxtMHreVszo0ehw6gnsabw7fpgDv8ztYcMNj4A22ZTyfTAQrSZ534D7iDkWgHi2my82b31MsnlQzQ==", "license": "Apache-2.0", "peerDependencies": { "react-native": "*" } }, "node_modules/@ammarahmed/react-native-background-fetch": { - "version": "4.2.2", - "resolved": "https://registry.npmjs.org/@ammarahmed/react-native-background-fetch/-/react-native-background-fetch-4.2.2.tgz", - "integrity": "sha512-PLBlb/DD+6Fv1auxdD6VRxtuC7GKPhQqR69bovRm5oGavbdSzRr+ZTr8AyNMCcayxKGdgEX2JysrJg8WIySSFQ==", + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/@ammarahmed/react-native-background-fetch/-/react-native-background-fetch-4.2.3.tgz", + "integrity": "sha512-cgO9EEFoU1HYuDNMpdTTke7DYzEDQfLsyd/cWIZ5Lpp4zz76+dgp1+LBqbLYdSenhJU1Omghq3xWPsoWDRaemQ==", "license": "MIT" }, "node_modules/@ammarahmed/react-native-eventsource": { diff --git a/apps/mobile/package.json b/apps/mobile/package.json index b46eb7c2b..c0ad60cc6 100644 --- a/apps/mobile/package.json +++ b/apps/mobile/package.json @@ -26,8 +26,8 @@ "react": "19.1.1" }, "dependencies": { - "@ammarahmed/notifee-react-native": "^7.4.11", - "@ammarahmed/react-native-background-fetch": "^4.2.2", + "@ammarahmed/notifee-react-native": "^7.4.12", + "@ammarahmed/react-native-background-fetch": "^4.2.3", "@ammarahmed/react-native-eventsource": "1.1.0", "@ammarahmed/react-native-fingerprint-scanner": "^5.0.1", "@ammarahmed/react-native-share-extension": "^2.9.5",