Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enforce subscription check #2677

Merged
merged 4 commits into from
Apr 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 22 additions & 10 deletions DuckDuckGo/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -515,18 +515,30 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
presentVPNEarlyAccessOverAlert()

Task {
let controller = NetworkProtectionTunnelController()

if await controller.isConnected {
DailyPixel.fireDailyAndCount(pixel: .privacyProVPNBetaStoppedWhenPrivacyProEnabled, withAdditionalParameters: [
"reason": "thank-you-dialog"
])
}

await controller.stop()
await controller.removeVPN()
await self.stopAndRemoveVPN(with: "thank-you-dialog")
}
} else if vpnFeatureVisibility.isPrivacyProLaunched() && !AccountManager().isUserAuthenticated {
samsymons marked this conversation as resolved.
Show resolved Hide resolved
Task {
await self.stopAndRemoveVPN(with: "subscription-check")
}
}
}

private func stopAndRemoveVPN(with reason: String) async {
let controller = NetworkProtectionTunnelController()
guard await controller.isInstalled else {
return
}

let isConnected = await controller.isConnected

DailyPixel.fireDailyAndCount(pixel: .privacyProVPNBetaStoppedWhenPrivacyProEnabled, withAdditionalParameters: [
"reason": reason,
"vpn-connected": String(isConnected)
])

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

func updateSubscriptionStatus() {
Expand Down
Loading