-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #457 from ivpn/bugfix/ios18-shortcuts
[iOS 18] IVPN shortcuts are not available
- Loading branch information
Showing
12 changed files
with
198 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
// | ||
// AddNoteIntent.swift | ||
// IVPN iOS app | ||
// https://github.com/ivpn/ios-app | ||
// | ||
// Created by Juraj Hilje on 2024-09-04. | ||
// Copyright (c) 2024 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 <https://www.gnu.org/licenses/>. | ||
// | ||
|
||
|
||
import AppIntents | ||
|
||
@available(iOS 16, *) | ||
struct Connect: AppIntent { | ||
static var title = LocalizedStringResource("Connect VPN") | ||
static var description = IntentDescription("Connect to the VPN") | ||
|
||
func perform() async throws -> some IntentResult { | ||
log(.info, message: "App Intent handler: Connect") | ||
NotificationCenter.default.post(name: Notification.Name.IntentConnect, object: nil) | ||
return .result() | ||
} | ||
} | ||
|
||
@available(iOS 16, *) | ||
struct Disconnect: AppIntent { | ||
static var title = LocalizedStringResource("Disconnect VPN") | ||
static var description = IntentDescription("Disconnect from the VPN") | ||
|
||
func perform() async throws -> some IntentResult { | ||
log(.info, message: "App Intent handler: Disconnect") | ||
NotificationCenter.default.post(name: Notification.Name.IntentDisconnect, object: nil) | ||
return .result() | ||
} | ||
} | ||
|
||
@available(iOS 16, *) | ||
struct AntiTrackerEnable: AppIntent { | ||
static var title = LocalizedStringResource("Enable AntiTracker") | ||
static var description = IntentDescription("Enables the AntiTracker") | ||
|
||
func perform() async throws -> some IntentResult { | ||
log(.info, message: "App Intent handler: EnableAntiTracker") | ||
NotificationCenter.default.post(name: Notification.Name.IntentAntiTrackerEnable, object: nil) | ||
return .result() | ||
} | ||
} | ||
|
||
@available(iOS 16, *) | ||
struct AntiTrackerDisable: AppIntent { | ||
static var title = LocalizedStringResource("Disable AntiTracker") | ||
static var description = IntentDescription("Disables the AntiTracker") | ||
|
||
func perform() async throws -> some IntentResult { | ||
log(.info, message: "App Intent handler: DisableAntiTracker") | ||
NotificationCenter.default.post(name: Notification.Name.IntentAntiTrackerDisable, object: nil) | ||
return .result() | ||
} | ||
} | ||
|
||
@available(iOS 16, *) | ||
struct CustomDNSEnable: AppIntent { | ||
static var title = LocalizedStringResource("Enable Custom DNS") | ||
static var description = IntentDescription("Enables the Custom DNS") | ||
|
||
func perform() async throws -> some IntentResult { | ||
log(.info, message: "App Intent handler: EnableCustomDNS") | ||
NotificationCenter.default.post(name: Notification.Name.IntentCustomDNSEnable, object: nil) | ||
return .result() | ||
} | ||
} | ||
|
||
@available(iOS 16, *) | ||
struct CustomDNSDisable: AppIntent { | ||
static var title = LocalizedStringResource("Disable Custom DNS") | ||
static var description = IntentDescription("Disables the Custom DNS") | ||
|
||
func perform() async throws -> some IntentResult { | ||
log(.info, message: "App Intent handler: DisableCustomDNS") | ||
NotificationCenter.default.post(name: Notification.Name.IntentCustomDNSDisable, object: nil) | ||
return .result() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// | ||
// AppIntentsHandler.swift | ||
// IVPNClient | ||
// | ||
// Created by Juraj Hilje on 04.09.2024.. | ||
// Copyright © 2024 IVPN. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
|
||
extension MainViewController { | ||
|
||
// MARK: - App Intents - | ||
|
||
@objc func intentConnect() { | ||
Application.shared.connectionManager.resetRulesAndConnect() | ||
} | ||
|
||
@objc func intentDisconnect() { | ||
Application.shared.connectionManager.resetRulesAndDisconnect() | ||
} | ||
|
||
@objc func intentAntiTrackerEnable() { | ||
DispatchQueue.async { | ||
if Application.shared.settings.connectionProtocol.tunnelType() == .ipsec { | ||
self.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) | ||
self.evaluateReconnect(sender: self.view) | ||
} | ||
} | ||
|
||
@objc func intentAntiTrackerDisable() { | ||
DispatchQueue.async { | ||
UserDefaults.shared.set(false, forKey: UserDefaults.Key.isAntiTracker) | ||
NotificationCenter.default.post(name: Notification.Name.AntiTrackerUpdated, object: nil) | ||
self.evaluateReconnect(sender: self.view) | ||
} | ||
} | ||
|
||
@objc func intentCustomDNSEnable() { | ||
DispatchQueue.async { | ||
if Application.shared.settings.connectionProtocol.tunnelType() == .ipsec { | ||
self.showAlert(title: "IKEv2 not supported", message: "Custom DNS is supported only for OpenVPN and WireGuard protocols.") { _ in | ||
} | ||
return | ||
} | ||
|
||
guard !UserDefaults.shared.customDNS.isEmpty else { | ||
self.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) | ||
self.evaluateReconnect(sender: self.view) | ||
} | ||
} | ||
|
||
@objc func intentCustomDNSDisable() { | ||
DispatchQueue.async { | ||
UserDefaults.shared.set(false, forKey: UserDefaults.Key.isCustomDNS) | ||
NotificationCenter.default.post(name: Notification.Name.CustomDNSUpdated, object: nil) | ||
self.evaluateReconnect(sender: self.view) | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.