diff --git a/IVPNClient.xcodeproj/project.pbxproj b/IVPNClient.xcodeproj/project.pbxproj index b0e009176..4fd94b4f5 100644 --- a/IVPNClient.xcodeproj/project.pbxproj +++ b/IVPNClient.xcodeproj/project.pbxproj @@ -25,8 +25,6 @@ 8206BAFF29ED6FFF00F916B7 /* ConnectionInfoView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8206BAFE29ED6FFF00F916B7 /* ConnectionInfoView.swift */; }; 8206BB0129ED7BEE00F916B7 /* ConnectionInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8206BB0029ED7BEE00F916B7 /* ConnectionInfo.swift */; }; 8206BB0329ED7C3700F916B7 /* ConnectionInfoViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8206BB0229ED7C3700F916B7 /* ConnectionInfoViewModel.swift */; }; - 8206E5D022967E37003119AF /* UserActivityType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8206E5CF22967E37003119AF /* UserActivityType.swift */; }; - 8206E5D222967EAF003119AF /* UserActivityTitle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8206E5D122967EAF003119AF /* UserActivityTitle.swift */; }; 8206F32124347A8F0056B465 /* MainView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8206F32024347A8F0056B465 /* MainView.swift */; }; 8206F32324367A240056B465 /* VPNErrorObserver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8206F32224367A240056B465 /* VPNErrorObserver.swift */; }; 8208525623FD56870008C112 /* FloatingPanelMainLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8208525523FD56870008C112 /* FloatingPanelMainLayout.swift */; }; @@ -473,8 +471,6 @@ 8206BAFE29ED6FFF00F916B7 /* ConnectionInfoView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConnectionInfoView.swift; sourceTree = ""; }; 8206BB0029ED7BEE00F916B7 /* ConnectionInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConnectionInfo.swift; sourceTree = ""; }; 8206BB0229ED7C3700F916B7 /* ConnectionInfoViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConnectionInfoViewModel.swift; sourceTree = ""; }; - 8206E5CF22967E37003119AF /* UserActivityType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserActivityType.swift; sourceTree = ""; }; - 8206E5D122967EAF003119AF /* UserActivityTitle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserActivityTitle.swift; sourceTree = ""; }; 8206F32024347A8F0056B465 /* MainView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainView.swift; sourceTree = ""; }; 8206F32224367A240056B465 /* VPNErrorObserver.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VPNErrorObserver.swift; sourceTree = ""; }; 8208525523FD56870008C112 /* FloatingPanelMainLayout.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FloatingPanelMainLayout.swift; sourceTree = ""; }; @@ -1198,8 +1194,6 @@ 82E716832181E8E100D6B7C2 /* ProviderConfigurationKeys.swift */, 82D598B321A5A7A3000FABDE /* NetworkTrust.swift */, 82D598C721A6ADF1000FABDE /* NetworkType.swift */, - 8206E5CF22967E37003119AF /* UserActivityType.swift */, - 8206E5D122967EAF003119AF /* UserActivityTitle.swift */, 823FFB062338DF1800F91A5D /* Capability.swift */, 8229209F2480FA3600476FC1 /* ServersSort.swift */, 826FBDA22461847D00B9E464 /* ServiceType.swift */, @@ -2291,7 +2285,6 @@ 82D598BC21A6949F000FABDE /* StorageManager.swift in Sources */, 826FBDA32461847D00B9E464 /* ServiceType.swift in Sources */, 821429B922FC2EA40056B8FF /* ApiService+Ext.swift in Sources */, - 8206E5D222967EAF003119AF /* UserActivityTitle.swift in Sources */, 82E716902181E90500D6B7C2 /* ConnectionSettings.swift in Sources */, 8223C54C22E9E93A00CD283D /* Session.swift in Sources */, 822563922431E03A00AE7F8D /* AccountView.swift in Sources */, @@ -2364,7 +2357,6 @@ 82A3422524AB6AF700761AB0 /* Double+Ext.swift in Sources */, 8221377B2227E75E001E1BF5 /* CustomDNSViewController.swift in Sources */, 9C3031351DB42EF900C38B0C /* Application.swift in Sources */, - 8206E5D022967E37003119AF /* UserActivityType.swift in Sources */, 82A6D74A24A3780B00D6C0E1 /* ConnectToServerPopupView.swift in Sources */, 828772FB221C28E000D5E330 /* FlagImageView.swift in Sources */, 8228C8D22B1DE906005977D3 /* PurchaseManager.swift in Sources */, diff --git a/IVPNClient/AppDelegate.swift b/IVPNClient/AppDelegate.swift index 1753b0197..8285dff0e 100644 --- a/IVPNClient/AppDelegate.swift +++ b/IVPNClient/AppDelegate.swift @@ -178,99 +178,6 @@ class AppDelegate: UIResponder { } } - private func userActivityConnect() { - DispatchQueue.delay(0.75) { - if UserDefaults.shared.networkProtectionEnabled { - Application.shared.connectionManager.resetRulesAndConnectShortcut(closeApp: true, actionType: .connect) - return - } - Application.shared.connectionManager.connectShortcut(closeApp: true, actionType: .connect) - } - } - - private func userActivityDisconnect() { - DispatchQueue.delay(0.75) { - if UserDefaults.shared.networkProtectionEnabled { - Application.shared.connectionManager.resetRulesAndDisconnectShortcut(closeApp: true, actionType: .disconnect) - return - } - Application.shared.connectionManager.disconnectShortcut(closeApp: true, actionType: .disconnect) - } - } - - private func userActivityAntiTrackerEnable() { - DispatchQueue.async { - if let viewController = UIApplication.topViewController() { - if Application.shared.settings.connectionProtocol.tunnelType() == .ipsec { - viewController.showAlert(title: "IKEv2 not supported", message: "AntiTracker is supported only for OpenVPN and WireGuard protocols.") { _ in - } - return - } - - UserDefaults.shared.set(true, forKey: UserDefaults.Key.isAntiTracker) - NotificationCenter.default.post(name: Notification.Name.AntiTrackerUpdated, object: nil) - if UIApplication.topViewController() as? MainViewController != nil { - NotificationCenter.default.post(name: Notification.Name.EvaluateReconnect, object: nil) - } else { - viewController.evaluateReconnect(sender: viewController.view) - } - } - } - } - - private func userActivityAntiTrackerDisable() { - DispatchQueue.async { - if let viewController = UIApplication.topViewController() { - UserDefaults.shared.set(false, forKey: UserDefaults.Key.isAntiTracker) - NotificationCenter.default.post(name: Notification.Name.AntiTrackerUpdated, object: nil) - if UIApplication.topViewController() as? MainViewController != nil { - NotificationCenter.default.post(name: Notification.Name.EvaluateReconnect, object: nil) - } else { - viewController.evaluateReconnect(sender: viewController.view) - } - } - } - } - - private func userActivityCustomDNSEnable() { - DispatchQueue.async { - if let viewController = UIApplication.topViewController() { - if Application.shared.settings.connectionProtocol.tunnelType() == .ipsec { - viewController.showAlert(title: "IKEv2 not supported", message: "Custom DNS is supported only for OpenVPN and WireGuard protocols.") { _ in - } - return - } - - guard !UserDefaults.shared.customDNS.isEmpty else { - viewController.showAlert(title: "", message: "Please enter DNS server info") - return - } - - UserDefaults.shared.set(true, forKey: UserDefaults.Key.isCustomDNS) - NotificationCenter.default.post(name: Notification.Name.CustomDNSUpdated, object: nil) - if UIApplication.topViewController() as? MainViewController != nil { - NotificationCenter.default.post(name: Notification.Name.EvaluateReconnect, object: nil) - } else { - viewController.evaluateReconnect(sender: viewController.view) - } - } - } - } - - private func userActivityCustomDNSDisable() { - DispatchQueue.async { - if let viewController = UIApplication.topViewController() { - UserDefaults.shared.set(false, forKey: UserDefaults.Key.isCustomDNS) - NotificationCenter.default.post(name: Notification.Name.CustomDNSUpdated, object: nil) - if UIApplication.topViewController() as? MainViewController != nil { - NotificationCenter.default.post(name: Notification.Name.EvaluateReconnect, object: nil) - } else { - viewController.evaluateReconnect(sender: viewController.view) - } - } - } - } - private func startPurchaseObserver() { PurchaseManager.shared.delegate = self PurchaseManager.shared.startObserver() @@ -361,37 +268,6 @@ extension AppDelegate: UIApplicationDelegate { return true } - func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool { - if let url = userActivity.webpageURL { - let endpoint = url.lastPathComponent - handleURLEndpoint(endpoint) - return false - } - - guard Application.shared.authentication.isLoggedIn, Application.shared.serviceStatus.isActive else { - return false - } - - switch userActivity.activityType { - case UserActivityType.Connect: - userActivityConnect() - case UserActivityType.Disconnect: - userActivityDisconnect() - case UserActivityType.AntiTrackerEnable: - userActivityAntiTrackerEnable() - case UserActivityType.AntiTrackerDisable: - userActivityAntiTrackerDisable() - case UserActivityType.CustomDNSEnable: - userActivityCustomDNSEnable() - case UserActivityType.CustomDNSDisable: - userActivityCustomDNSDisable() - default: - log(.info, message: "No such user activity") - } - - return false - } - } // MARK: - PurchaseManagerDelegate - diff --git a/IVPNClient/Enums/UserActivityTitle.swift b/IVPNClient/Enums/UserActivityTitle.swift deleted file mode 100644 index 74c4590fb..000000000 --- a/IVPNClient/Enums/UserActivityTitle.swift +++ /dev/null @@ -1,33 +0,0 @@ -// -// UserActivityTitle.swift -// IVPN iOS app -// https://github.com/ivpn/ios-app -// -// Created by Juraj Hilje on 2019-05-23. -// Copyright (c) 2023 IVPN Limited. -// -// This file is part of the IVPN iOS app. -// -// The IVPN iOS app is free software: you can redistribute it and/or -// modify it under the terms of the GNU General Public License as published by the Free -// Software Foundation, either version 3 of the License, or (at your option) any later version. -// -// The IVPN iOS app is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more -// details. -// -// You should have received a copy of the GNU General Public License -// along with the IVPN iOS app. If not, see . -// - -import Foundation - -enum UserActivityTitle { - static let Connect = "Connect" - static let Disconnect = "Disconnect" - static let AntiTrackerEnable = "Enable AntiTracker" - static let AntiTrackerDisable = "Disable AntiTracker" - static let CustomDNSEnable = "Enable CustomDNS" - static let CustomDNSDisable = "Disable CustomDNS" -} diff --git a/IVPNClient/Enums/UserActivityType.swift b/IVPNClient/Enums/UserActivityType.swift deleted file mode 100644 index d0be60601..000000000 --- a/IVPNClient/Enums/UserActivityType.swift +++ /dev/null @@ -1,33 +0,0 @@ -// -// UserActivityType.swift -// IVPN iOS app -// https://github.com/ivpn/ios-app -// -// Created by Juraj Hilje on 2019-05-23. -// Copyright (c) 2023 IVPN Limited. -// -// This file is part of the IVPN iOS app. -// -// The IVPN iOS app is free software: you can redistribute it and/or -// modify it under the terms of the GNU General Public License as published by the Free -// Software Foundation, either version 3 of the License, or (at your option) any later version. -// -// The IVPN iOS app is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more -// details. -// -// You should have received a copy of the GNU General Public License -// along with the IVPN iOS app. If not, see . -// - -import Foundation - -enum UserActivityType { - static let Connect = "net.ivpn.clients.ios.Connect" - static let Disconnect = "net.ivpn.clients.ios.Disconnect" - static let AntiTrackerEnable = "net.ivpn.clients.ios.AntiTracker.enable" - static let AntiTrackerDisable = "net.ivpn.clients.ios.AntiTracker.disable" - static let CustomDNSEnable = "net.ivpn.clients.ios.CustomDNS.enable" - static let CustomDNSDisable = "net.ivpn.clients.ios.CustomDNS.disable" -} diff --git a/IVPNClient/Scenes/MainScreen/ControlPanel/ControlPanelViewController.swift b/IVPNClient/Scenes/MainScreen/ControlPanel/ControlPanelViewController.swift index 12ec8e37d..dbfb5043f 100644 --- a/IVPNClient/Scenes/MainScreen/ControlPanel/ControlPanelViewController.swift +++ b/IVPNClient/Scenes/MainScreen/ControlPanel/ControlPanelViewController.swift @@ -108,12 +108,6 @@ class ControlPanelViewController: UITableViewController { WidgetCenter.shared.reloadTimelines(ofKind: "IVPNWidget") evaluateReconnect(sender: sender as UIView) controlPanelView.updateAntiTracker(viewModel: vpnStatusViewModel) - - if sender.isOn { - registerUserActivity(type: UserActivityType.AntiTrackerEnable, title: UserActivityTitle.AntiTrackerEnable) - } else { - registerUserActivity(type: UserActivityType.AntiTrackerDisable, title: UserActivityTitle.AntiTrackerDisable) - } } @IBAction func selectIpProtocol(_ sender: UISegmentedControl) { @@ -223,8 +217,6 @@ class ControlPanelViewController: UITableViewController { manager.resetRulesAndConnect() } - registerUserActivity(type: UserActivityType.Connect, title: UserActivityTitle.Connect) - NotificationCenter.default.removeObserver(self, name: Notification.Name.ServiceAuthorized, object: nil) NotificationCenter.default.removeObserver(self, name: Notification.Name.SubscriptionActivated, object: nil) } @@ -240,8 +232,6 @@ class ControlPanelViewController: UITableViewController { manager.resetRulesAndDisconnect() } - registerUserActivity(type: UserActivityType.Disconnect, title: UserActivityTitle.Disconnect) - DispatchQueue.delay(0.5) { if Application.shared.connectionManager.status.isDisconnected() { Pinger.shared.ping() diff --git a/IVPNClient/Scenes/ViewControllers/AntiTrackerViewController.swift b/IVPNClient/Scenes/ViewControllers/AntiTrackerViewController.swift index 4b4a518e5..3c35b036f 100644 --- a/IVPNClient/Scenes/ViewControllers/AntiTrackerViewController.swift +++ b/IVPNClient/Scenes/ViewControllers/AntiTrackerViewController.swift @@ -46,12 +46,6 @@ class AntiTrackerViewController: UITableViewController { antiTrackerHardcoreSwitch.isEnabled = sender.isOn evaluateReconnect(sender: sender as UIView) NotificationCenter.default.post(name: Notification.Name.UpdateControlPanel, object: nil) - - if sender.isOn { - registerUserActivity(type: UserActivityType.AntiTrackerEnable, title: UserActivityTitle.AntiTrackerEnable) - } else { - registerUserActivity(type: UserActivityType.AntiTrackerDisable, title: UserActivityTitle.AntiTrackerDisable) - } } @IBAction func toggleAntiTrackerHardcore(_ sender: UISwitch) { diff --git a/IVPNClient/Scenes/ViewControllers/CustomDNSViewController.swift b/IVPNClient/Scenes/ViewControllers/CustomDNSViewController.swift index bf86e317a..2fcbe5a3d 100644 --- a/IVPNClient/Scenes/ViewControllers/CustomDNSViewController.swift +++ b/IVPNClient/Scenes/ViewControllers/CustomDNSViewController.swift @@ -53,12 +53,6 @@ class CustomDNSViewController: UITableViewController { UserDefaults.shared.set(sender.isOn, forKey: UserDefaults.Key.isCustomDNS) evaluateReconnect(sender: sender) - - if sender.isOn { - registerUserActivity(type: UserActivityType.CustomDNSEnable, title: UserActivityTitle.CustomDNSEnable) - } else { - registerUserActivity(type: UserActivityType.CustomDNSDisable, title: UserActivityTitle.CustomDNSDisable) - } } @IBAction func enableSecureDNS(_ sender: UISwitch) { diff --git a/IVPNClient/Utilities/Extensions/UIViewController+Ext.swift b/IVPNClient/Utilities/Extensions/UIViewController+Ext.swift index 362af3e8c..9f1705d21 100644 --- a/IVPNClient/Utilities/Extensions/UIViewController+Ext.swift +++ b/IVPNClient/Utilities/Extensions/UIViewController+Ext.swift @@ -95,16 +95,6 @@ extension UIViewController { openWebPage("https://www.ivpn.net/privacy-mobile-app/") } - func registerUserActivity(type: String, title: String) { - let activity = NSUserActivity(activityType: type) - activity.title = title - activity.isEligibleForSearch = true - activity.isEligibleForPrediction = true - - userActivity = activity - userActivity?.becomeCurrent() - } - func hideKeyboardOnTap() { let tap: UITapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(UIViewController.dismissKeyboard)) tap.cancelsTouchesInView = false