How to use NetworkReachabilityManager in Alamofire

NetworkManager Class class NetworkManager { //shared instance static let shared = NetworkManager() let reachabilityManager = Alamofire.NetworkReachabilityManager(host: “www.google.com”) func startNetworkReachabilityObserver() { reachabilityManager?.listener = { status in switch status { case .notReachable: print(“The network is not reachable”) case .unknown : print(“It is unknown whether the network is reachable”) case .reachable(.ethernetOrWiFi): print(“The network is reachable over the WiFi … Read more

How to tell if ‘Mobile Network Data’ is enabled or disabled (even when connected by WiFi)?

The following code will tell you if “mobile data” is enabled or not, regardless of whether or not there is a mobile data connection active at the moment or whether or not wifi is enabled/active or not. This code only works on Android 2.3 (Gingerbread) and later. Actually this code also works on earlier versions … Read more

How to detect online/offline event cross-browser?

Currently in 2011, the various browser vendors cannot agree on how to define offline. Some browsers have a Work Offline feature, which they consider separate to a lack of network access, which again is different to internet access. The whole thing is a mess. Some browser vendors update the navigator.onLine flag when actual network access … Read more