Skip to content

Commit

Permalink
Stop tunnel
Browse files Browse the repository at this point in the history
  • Loading branch information
quanganhdo committed Mar 27, 2024
1 parent a0304cd commit c2d7cd4
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions DuckDuckGo/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -499,8 +499,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
#if NETWORK_PROTECTION
widgetRefreshModel.refreshVPNWidget()

if vpnFeatureVisibility.shouldShowThankYouMessaging() && !tunnelDefaults.vpnEarlyAccessOverAlertAlreadyShown {
presentVPNEarlyAccessOverAlert()
if vpnFeatureVisibility.shouldShowThankYouMessaging() {
stopTunnelAndShowThankYouMessagingIfNeeded()
}

if tunnelDefaults.showEntitlementAlert {
Expand All @@ -513,6 +513,25 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
updateSubscriptionStatus()
}

private func stopTunnelAndShowThankYouMessagingIfNeeded() {
Task {
let controller = NetworkProtectionTunnelController()

if await controller.isConnected {
DailyPixel.fireDailyAndCount(pixel: .privacyProVPNBetaStoppedWhenPrivacyProEnabled)
}

await controller.stop()
await controller.removeVPN()

if !tunnelDefaults.vpnEarlyAccessOverAlertAlreadyShown {
await MainActor.run {
self.presentVPNEarlyAccessOverAlert()
}
}
}
}

func updateSubscriptionStatus() {
#if SUBSCRIPTION
Task {
Expand Down

0 comments on commit c2d7cd4

Please sign in to comment.