High performance self-hosted photo and video management solution.
TypeScript backup-toolfluttergoogle-photosgoogle-photos-alternativejavascriptmobile-appnestjsnodejsphoto-galleryphotosphotos-managementself-hostedsveltesveltekittypescriptvideos
feat(mobile): Adds WiFi only backup option to iOS (#6724)
martyfuhry0d876a470f2b
diff --git a/mobile/ios/Runner/BackgroundSync/BackgroundServicePlugin.swift b/mobile/ios/Runner/BackgroundSync/BackgroundServicePlugin.swiftindex 8e5db08b1e..c84b037daf 100644--- a/mobile/ios/Runner/BackgroundSync/BackgroundServicePlugin.swift+++ b/mobile/ios/Runner/BackgroundSync/BackgroundServicePlugin.swift@@ -9,6 +9,7 @@ import Flutterimport BackgroundTasksimport path_provider_foundationimport CryptoKit+import Networkclass BackgroundServicePlugin: NSObject, FlutterPlugin {@@ -335,8 +336,8 @@ class BackgroundServicePlugin: NSObject, FlutterPlugin {defaults.set(Date().timeIntervalSince1970, forKey: "last_background_fetch_run_time")// If we have required charging, we should check the charging status- let requireCharging = defaults.value(forKey: "require_charging") as? Bool- if (requireCharging ?? false) {+ let requireCharging = defaults.value(forKey: "require_charging") as? Bool ?? false+ if (requireCharging) {UIDevice.current.isBatteryMonitoringEnabled = trueif (UIDevice.current.batteryState == .unplugged) {// The device is unplugged and we have required charging@@ -347,6 +348,20 @@ class BackgroundServicePlugin: NSObject, FlutterPlugin {}}+ // If we have required Wi-Fi, we can check the isExpensive property+ let requireWifi = defaults.value(forKey: "require_wifi") as? Bool ?? false+ if (requireWifi) {+ let wifiMonitor = NWPathMonitor(requiredInterfaceType: .wifi)+ let isExpensive = wifiMonitor.currentPath.isExpensive+ if (isExpensive) {+ // The network is expensive and we have required Wi-Fi+ // Therfore, we will simply complete the task without+ // running it+ task.setTaskCompleted(success: true)+ return+ }+ }+// Schedule the next sync task so we can run this again laterscheduleBackgroundFetch()diff --git a/mobile/lib/modules/backup/views/backup_options_page.dart b/mobile/lib/modules/backup/views/backup_options_page.dartindex c3beb2f8c5..8144f1b8ed 100644--- a/mobile/lib/modules/backup/views/backup_options_page.dart+++ b/mobile/lib/modules/backup/views/backup_options_page.dart@@ -264,7 +264,7 @@ class BackupOptionsPage extends HookConsumerWidget {"backup_controller_page_background_description",).tr(),),- if (isBackgroundEnabled && Platform.isAndroid)+ if (isBackgroundEnabled)SwitchListTile.adaptive(title: const Text("backup_controller_page_background_wifi").tr(),