add toggle

This commit is contained in:
Benjamin Faershtein 2026-01-17 14:54:44 -08:00
parent 74d2e562f0
commit 8499a102d0
3 changed files with 16 additions and 2 deletions

View file

@ -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

View file

@ -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"

View file

@ -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<Bool>(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 {