diff --git a/Meshtastic/Extensions/UserDefaults.swift b/Meshtastic/Extensions/UserDefaults.swift index 82e67773..232e0f45 100644 --- a/Meshtastic/Extensions/UserDefaults.swift +++ b/Meshtastic/Extensions/UserDefaults.swift @@ -67,6 +67,7 @@ extension UserDefaults { case enableDetectionNotifications case detectionSensorRole case enableSmartPosition + case positionShareNotifications case newNodeNotifications case lowBatteryNotifications case channelMessageNotifications @@ -139,6 +140,9 @@ extension UserDefaults { @UserDefault(.enableSmartPosition, defaultValue: false) static var enableSmartPosition: Bool + @UserDefault(.positionShareNotifications, defaultValue: true) + static var positionShareNotifications: Bool + @UserDefault(.channelMessageNotifications, defaultValue: true) static var channelMessageNotifications: Bool diff --git a/Meshtastic/Persistence/UpdateCoreData.swift b/Meshtastic/Persistence/UpdateCoreData.swift index 8e869027..6eb0fc4b 100644 --- a/Meshtastic/Persistence/UpdateCoreData.swift +++ b/Meshtastic/Persistence/UpdateCoreData.swift @@ -666,7 +666,7 @@ private func createPositionMessageEntity( } } - if !(newMessage.fromUser?.mute ?? false) { + if !(newMessage.fromUser?.mute ?? false) && UserDefaults.positionShareNotifications { // Create an iOS Notification for the received DM position let manager = LocalNotificationManager() let notificationContent = "📍 Shared their location" @@ -699,7 +699,7 @@ private func createPositionMessageEntity( if channel.index == newMessage.channel { context.refresh(channel, mergeChanges: true) } - if channel.index == newMessage.channel && !channel.mute && UserDefaults.channelMessageNotifications { + if channel.index == newMessage.channel && !channel.mute && UserDefaults.channelMessageNotifications && UserDefaults.positionShareNotifications { // Create an iOS Notification for the received channel position let manager = LocalNotificationManager() let notificationContent = "📍 Shared their location" diff --git a/Meshtastic/Views/Settings/AppSettings.swift b/Meshtastic/Views/Settings/AppSettings.swift index 2f10c2af..fdc34fef 100644 --- a/Meshtastic/Views/Settings/AppSettings.swift +++ b/Meshtastic/Views/Settings/AppSettings.swift @@ -20,6 +20,7 @@ struct AppSettings: View { @AppStorage("environmentEnableWeatherKit") private var environmentEnableWeatherKit: Bool = true @AppStorage("enableAdministration") private var enableAdministration: Bool = false @AppStorage("usageDataAndCrashReporting") private var usageDataAndCrashReporting: Bool = true + @AppStorage("positionShareNotifications") private var positionShareNotifications: Bool = true let autoconnectBinding = Binding(get: { return UserDefaults.autoconnectOnDiscovery @@ -78,6 +79,15 @@ struct AppSettings: View { .tint(.accentColor) } } + Section(header: Text("Notifications")) { + Toggle(isOn: $positionShareNotifications) { + Label("Shared Locations", systemImage: "location.fill") + } + .tint(.accentColor) + Text("Notifications for shared location messages from other users.") + .foregroundStyle(.secondary) + .font(.caption) + } Section(header: Text("App Data")) { Toggle(isOn: $purgeStaleNodes ) { Label {