@@ -17,6 +17,8 @@ private func registerAdvancedOptionsDefault() {
1717 let enabled = os. majorVersion >= 19
1818 UserDefaults . standard. register ( defaults: [ " enableAdvancedOptions " : enabled] )
1919 UserDefaults . standard. register ( defaults: [ " enablePiP " : enabled] )
20+ // New default: VPN auto start enabled
21+ UserDefaults . standard. register ( defaults: [ " vpnAutoStart " : true ] )
2022}
2123
2224// MARK: - Welcome Sheet
@@ -487,6 +489,7 @@ struct HeartbeatApp: App {
487489 @AppStorage ( " hasLaunchedBefore " ) var hasLaunchedBefore : Bool = false
488490 @AppStorage ( " customAccentColor " ) private var customAccentColorHex : String = " "
489491 @AppStorage ( " appTheme " ) private var appThemeRaw : String = AppTheme . system. rawValue
492+ @AppStorage ( " vpnAutoStart " ) private var vpnAutoStart : Bool = true
490493 @State private var showWelcomeSheet : Bool = false
491494 @State private var isLoading2 = true
492495 @State private var isPairing = false
@@ -717,10 +720,10 @@ struct HeartbeatApp: App {
717720 . tint ( globalAccent)
718721 . onAppear {
719722 // On first launch, present the welcome sheet.
720- // Otherwise, start the VPN automatically.
723+ // Otherwise, start the VPN automatically (if enabled) .
721724 if !hasLaunchedBefore {
722725 showWelcomeSheet = true
723- } else {
726+ } else if vpnAutoStart {
724727 TunnelManager . shared. startVPN ( )
725728 }
726729 // Update UIKit tint now and subscribe to changes without capturing self
@@ -735,10 +738,12 @@ struct HeartbeatApp: App {
735738 }
736739 . sheet ( isPresented: $showWelcomeSheet) {
737740 WelcomeSheetView {
738- // When the user taps "Continue", mark the app as launched and start the VPN.
741+ // When the user taps "Continue", mark the app as launched and start the VPN (if enabled) .
739742 hasLaunchedBefore = true
740743 showWelcomeSheet = false
741- TunnelManager . shared. startVPN ( )
744+ if vpnAutoStart {
745+ TunnelManager . shared. startVPN ( )
746+ }
742747 }
743748 }
744749 }
0 commit comments