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 detect Network Signal Strength in iOS Reachability

My original thought was to time the download of a file, and see how long it takes: @interface ViewController () <NSURLSessionDelegate, NSURLSessionDataDelegate> @property (nonatomic) CFAbsoluteTime startTime; @property (nonatomic) CFAbsoluteTime stopTime; @property (nonatomic) long long bytesReceived; @property (nonatomic, copy) void (^speedTestCompletionHandler)(CGFloat megabytesPerSecond, NSError *error); @end @implementation ViewController – (void)viewDidLoad { [super viewDidLoad]; [self testDownloadSpeedWithTimout:5.0 completionHandler:^(CGFloat megabytesPerSecond, … Read more

How to use reachability class to detect valid internet connection?

EDITED: If you want to check reachability before some code execution you should just use Reachability *reachability = [Reachability reachabilityForInternetConnection]; NetworkStatus internetStatus = [reachability currentReachabilityStatus]; if (internetStatus != NotReachable) { //my web-dependent code } else { //there-is-no-connection warning } You can also add a reachability observer somewhere (i.e. in viewDidLoad): Reachability *reachabilityInfo; [[NSNotificationCenter defaultCenter] addObserver:self … Read more

How to check internet connection in alamofire?

For swift 5 and Alamofire 5.4.4 ,I created a swift class called Connectivity . Use NetworkReachabilityManager class from Alamofire and configure the isConnectedToInternet() method as per your need. import Foundation import Alamofire class Connectivity { class func isConnectedToInternet() -> Bool { return NetworkReachabilityManager()?.isReachable ?? false } } Usage: if Connectivity.isConnectedToInternet() { print(“Yes! internet is available.”) … Read more

Detecting Network Connectivity Changes using Reachability, NSNotification and Network Link Conditioner in Swift

You must create a Reachability object before you can receive notifications from it. Also, be sure to call the startNotifier() method on the Reachability object you create. This would be an example of how to do so inside of your application delegate: class AppDelegate: UIResponder, UIApplicationDelegate { private var reachability:Reachability!; func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: … Read more

Reachability Guide for iOS

I have implemented Reachability like this. Download https://developer.apple.com/library/content/samplecode/Reachability/Introduction/Intro.html and add Reachability.h and .m to your project. Add the SystemConfiguration framework to your project. #import “Reachability.h” where you want to use it. Use this code. -(BOOL)reachable { Reachability *r = [Reachability reachabilityWithHostName:@”enbr.co.cc”]; NetworkStatus internetStatus = [r currentReachabilityStatus]; if(internetStatus == NotReachable) { return NO; } return YES; … Read more

iPhone reachability checking

From your screen shot, it seems like you do not have Reachability added to your project. You must download Reachability from Apple: https://developer.apple.com/library/content/samplecode/Reachability/Introduction/Intro.html And add both .h and .m files to your project. Update: You noted you have Reachability. But looking at the most recent version, I can see why you have the errors you … Read more

iOS Detect 3G or WiFi

Using the code that Apple has provided here Reachability *reachability = [Reachability reachabilityForInternetConnection]; [reachability startNotifier]; NetworkStatus status = [reachability currentReachabilityStatus]; if(status == NotReachable) { //No internet } else if (status == ReachableViaWiFi) { //WiFi } else if (status == ReachableViaWWAN) { //3G }