CHTReachability
CHTReachability copied to clipboard
A real network reachability library for iOS.
CHTReachability
Your device may connect to a wireless AP via Wi-Fi but the AP's cable is unplugged, or it may connect to a base station but your service provider stop working for some reasons. What's the easiest way to know current network status? CHTReachability tries to detect REAL network reachability for you.
Features
- Easy to use.
- Highly customizable.
Prerequisite
- ARC
- iOS 8+
How it works
It uses Apple's Reachability and SimplePing sample codes to do the real works.
- First it uses Reachability to check network reachability.
- When network status is
Reachablethen it uses SimplePing to ping specified host. - The status changes from
ReachabletoOnlineif it receives packet.
How to install
CocoaPods
You can use CocoaPods to install CHTReachability by adding it to your Podfile:
platform :ios, '8.0'
# If you're using Swift, remember to `use_frameworks!`
use_frameworks!
pod 'CHTReachability'
To get the full benefits import CHTReachability wherever you import UIKit
Swift
import UIKit
import CHTReachability
Objective-C
#import <CHTReachability/CHTReachability.h>
Manually
- Copy
CHTReachability.h/mto your project. - Copy
Venderfolder to your project. - Add
SystemConfiguration.framework.
How to Use
Check the demo codes and CHTReachability.h header file for more information.
- (void)viewDidLoad {
[super viewDidLoad];
self.reach = [[CHTReachability alloc] initWithHostName:CHTReachabilityDefaultPingHostName delegate:self];
}
#pragma mark - <CHTReachabilityDelegate>
- (void)reachability:(CHTReachability *)reachability didChangeToStatus:(CHTReachabilityStatus)status {
NSLog(@"Status = %@", @(status));
}
License
CHTReachability is available under the MIT license. See the LICENSE file for more info.
Changelog
Refer to the releases page.

