CocoaPods trunk is moving to be read-only. Read more on the blog, there are 9 months to go.
| TestsTested | ✗ |
| LangLanguage | SwiftSwift |
| License | MIT |
| ReleasedLast Release | Dec 2017 |
| SPMSupports SPM | ✓ |
Maintained by Ivan Magda.
IMNetworkReachability is a reachability framework. It is designed to help you interface with network activity events. It allows you to monitor network state synchronously and asynchronously.
let reachability = IMNetworkReachability("www.google.com")
switch reachability.isReachable() {
case .reachable:
print("Reachable")
case .offline:
print("Offline")
case .error(let error):
print("Failed to check for a network reachability, error: \(error)")
}// Declare this property where it won't go out of scope relative to your listener
let reachability = IMNetworkReachability("www.google.com")
reachability.startListening { (result) in
// this is called on a main thread
switch result {
case .reachable:
print("Reachable")
case .offline:
print("Offline")
case .error(let error):
print("Failed to check for a network reachability, error: \(error)")
}
}and for stopping notifications
reachability.stopListening()Also, don't forget to enable network access on macOS.
IMNetworkReachability supports multiple methods for installing the library in a project.
To integrate IMNetworkReachability into your Xcode project using CocoaPods, specify it in your Podfile:
source 'https://github.com/CocoaPods/Specs.git'
target 'iOS' do
platform :ios, '8.0'
use_frameworks!
pod 'IMNetworkReachability', '~> 0.1'
end
target 'macOS' do
platform :osx, '10.9'
use_frameworks!
pod 'IMNetworkReachability', '~> 0.1'
end
target 'tvOS' do
platform :tvos, '9.0'
use_frameworks!
pod 'IMNetworkReachability', '~> 0.1'
end
Then, run the following command:
$ pod installI'm Ivan Magda. Email: [email protected]. Twitter: @magda_ivan.
This project is open-sourced software licensed under the MIT License.
See the LICENSE file for more information.