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

[iOS 18] Privacy overlay not appearing when entering background #454

Merged
merged 2 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
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
11 changes: 2 additions & 9 deletions IVPNClient/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,9 @@ class AppDelegate: UIResponder {

private func showSecurityScreen() {
var showWindow = false
let topVC = UIApplication.topViewController()

if UIApplication.topViewController() as? AccountViewController != nil {
showWindow = true
}

if UIApplication.topViewController() as? LoginViewController != nil {
showWindow = true
}

if UIApplication.topViewController() as? CreateAccountViewController != nil {
if topVC is AccountViewController || topVC is LoginViewController || topVC is CreateAccountViewController {
showWindow = true
}

Expand Down
13 changes: 2 additions & 11 deletions IVPNClient/Managers/ConnectionManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,6 @@ class ConnectionManager {
self.updateOpenVPNLogFile()
self.updateWireGuardLogFile()
self.reconnectAutomatically = false
if self.actionType == .connect {
self.evaluateCloseApp()
}
}
DispatchQueue.delay(2.5) {
if UserDefaults.shared.isV2ray && !V2RayCore.shared.reconnectWithV2ray {
Expand Down Expand Up @@ -128,10 +125,6 @@ class ConnectionManager {
}
}
}

if status == .disconnected && self.actionType == .disconnect {
self.evaluateCloseApp()
}

completion(status)
}
Expand Down Expand Up @@ -575,12 +568,10 @@ class ConnectionManager {
}
}

private func evaluateCloseApp() {
func evaluateCloseApp() {
if closeApp {
closeApp = false
DispatchQueue.delay(1.5) {
UIControl().sendAction(#selector(NSXPCConnection.suspend), to: UIApplication.shared, for: nil)
}
UIControl().sendAction(#selector(NSXPCConnection.suspend), to: UIApplication.shared, for: nil)
}
}

Expand Down
5 changes: 5 additions & 0 deletions IVPNClient/Scenes/MainScreen/MainViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@ class MainViewController: UIViewController {
if !model.isIvpnServer {
Application.shared.geoLookup = model
}

WidgetCenter.shared.reloadTimelines(ofKind: "IVPNWidget")
Application.shared.connectionManager.evaluateCloseApp()
case .failure:
controlPanel.controlPanelView.ipv4ViewModel = ProofsViewModel(displayMode: .error)
mainView.infoAlertViewModel.infoAlert = .connectionInfoFailure
Expand All @@ -180,6 +183,8 @@ class MainViewController: UIViewController {
case .success(let model):
controlPanel.controlPanelView.ipv6ViewModel = ProofsViewModel(model: model, displayMode: .content)
mainView.ipv6ViewModel = ProofsViewModel(model: model)
WidgetCenter.shared.reloadTimelines(ofKind: "IVPNWidget")
Application.shared.connectionManager.evaluateCloseApp()
case .failure:
controlPanel.controlPanelView.ipv6ViewModel = ProofsViewModel(displayMode: .error)
mainView.ipv6ViewModel = ProofsViewModel(displayMode: .error)
Expand Down
2 changes: 1 addition & 1 deletion IVPNClient/Utilities/Extensions/UIApplication+Ext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ extension UIApplication {

var keyWindow: UIWindow? {
return self.connectedScenes
.filter { $0.activationState == .foregroundActive }
.filter { $0.activationState == .foregroundActive || $0.activationState == .foregroundInactive }
.first(where: { $0 is UIWindowScene })
.flatMap({ $0 as? UIWindowScene })?.windows
.first(where: \.isKeyWindow)
Expand Down
Loading