Meshtastic-Apple/Meshtastic/Helpers/NetworkManager.swift
Garth Vander Houwen ba3ef4af3e Managed Device
Delete by tile server
2023-05-13 20:50:20 -07:00

30 lines
608 B
Swift

//
// NetworkManager.swift
// Meshtastic
//
// Copyright(c) Garth Vander Houwen on 4/23/23.
//
import Foundation
import Network
class NetworkManager {
static let shared = NetworkManager()
// MARK: - Public methods
func runIfNetwork(completion: @escaping ()->() ) {
let pathMonitor = NWPathMonitor()
pathMonitor.pathUpdateHandler = {
guard $0.status == .satisfied else {
// No network available
print("Network Not available")
return pathMonitor.cancel()
}
pathMonitor.cancel()
completion()
}
pathMonitor.start(queue: DispatchQueue.global(qos: .background))
}
}