Files
Woka_Native_iOS/WOKA/Network Adapter/NetworkReachibility.swift
BilalKhanWDI 3de76138fc - Added the network library with proper versioning
- Made the network adapter
- Made the config file to hold the url auth
2024-05-07 11:12:59 +05:30

44 lines
1.3 KiB
Swift

//
// NetworkReachibility.swift
// WOKA
//
// Created by MacBook Pro on 06/05/24.
//
import Alamofire
class NetworkReachibility{
static let shared = NetworkReachibility()
private init(){}
let manager = NetworkReachabilityManager(host: "www.apple.com")
fileprivate var isInternetReachable = false
func startMonitoring(onCompletion : @escaping (Bool) -> Void) {
manager?.startListening(onQueue: DispatchQueue.main, onUpdatePerforming: { (status) in
switch status {
case .notReachable:
print("network connection status - lost")
self.isInternetReachable = false
onCompletion(false)
case .reachable(.ethernetOrWiFi):
print("network connection status - ethernet/WiFI")
self.isInternetReachable = true
onCompletion(true)
case .reachable(.cellular):
print("network connection status - cellular")
self.isInternetReachable = true
onCompletion(true)
default:
self.isInternetReachable = false
onCompletion(false)
break
}
})
}
func stopMonitoring(){
manager?.stopListening()
}
}