Swift Package Index


Swift Package designed as an alternative to detecting network connectivity when traditional methods do not work. Designed for iOS and macOS


  • The latest stable release is 1.0.0. Released almost 2 years ago.
  • The last commit to master was almost 2 years ago.

Swift Version Compatibility

  • 1.0.0 and master
    5.3
    5.2
    5.1
    5.0
    4.2
Full build results

Platform Compatibility

  • 1.0.0 and master
    iOS
    macOS(Intel)
    macOS(ARM)
    Linux
    tvOS
    watchOS
Full build results

NetworkConnectivity

Swift Package designed as an alternative to detecting network connectivity when traditional methods do not work. For example, Apple recommends that to properly check connectivity your application should send a network request and the request should let your application know the connectivity state of the device. If device is offline the request should fail immediately and you can provide the user with proper feedback. If the device is online the request will go out and you can also inform your user that the application is waiting for updated data.

In most cases this approach works great. There are some rare conditions that still exist that require your application to still check for the connectivity state of the device. For these rare cases the NetworkConnectivity package was built. NetworkConnectivity examines the state of a TCP connection and provides updates to a delegate method so your application can act accordingly.

class BaseViewController: ViewController {
    func viewDidLoad() {
        let _ = NetworkConnectivity.shared.setup(with: "agnosticdev.com")
    }
 }
 
extension BaseViewController: NetworkConnectivityDelegate {
    
    public func networkStatusChanged(online: Bool, connectivityStatus: String) {
        if online { 
            // handle online status
        } else {
            // handle offline status
        }
    }
}