Update VPN status after profile reinstall

Should now cover all scenarios.
This commit is contained in:
Davide De Rosa 2018-10-22 10:04:58 +02:00
parent 976e47af64
commit 9292919816
3 changed files with 10 additions and 1 deletions

View File

@ -88,6 +88,7 @@ class ServiceViewController: UIViewController, TableModelHost {
let nc = NotificationCenter.default
nc.addObserver(self, selector: #selector(applicationDidBecomeActive), name: UIApplication.didBecomeActiveNotification, object: nil)
nc.addObserver(self, selector: #selector(vpnDidUpdate), name: .VPNDidChangeStatus, object: nil)
nc.addObserver(self, selector: #selector(vpnDidUpdate), name: .VPNDidReinstall, object: nil)
// run this no matter what
// XXX: convenient here vs AppDelegate for updating table

View File

@ -37,7 +37,9 @@ class StandardVPNProvider: VPNProvider {
init(bundleIdentifier: String) {
self.bundleIdentifier = bundleIdentifier
NotificationCenter.default.addObserver(self, selector: #selector(vpnDidUpdate(_:)), name: .NEVPNStatusDidChange, object: nil)
let nc = NotificationCenter.default
nc.addObserver(self, selector: #selector(vpnDidUpdate(_:)), name: .NEVPNStatusDidChange, object: nil)
nc.addObserver(self, selector: #selector(vpnDidReinstall(_:)), name: .NEVPNConfigurationChange, object: nil)
}
deinit {
@ -264,4 +266,8 @@ class StandardVPNProvider: VPNProvider {
NotificationCenter.default.post(name: .VPNDidChangeStatus, object: self)
}
@objc private func vpnDidReinstall(_ notification: Notification) {
NotificationCenter.default.post(name: .VPNDidReinstall, object: self)
}
}

View File

@ -53,4 +53,6 @@ extension Notification.Name {
static let VPNDidPrepare = Notification.Name("VPNDidPrepare")
static let VPNDidChangeStatus = Notification.Name("VPNDidChangeStatus")
static let VPNDidReinstall = Notification.Name("VPNDidReinstall")
}