AsyncSwiftKits/ConnectivityKit
Modern networking support to monitor network connectivity
Usage
This package includes ConnectivityMonitor which internally uses NetworkMonitor or ReachabilityMonitor which are simply available as AnyConnectivityMonitor. For recent OS versions of iOS, macOS, tvOS and watchOS the NetworkMonitor will be used. For earlier versions ReachabilityMonitor will be used.
Simply call the start function and provide a path handler to get updates. Call the cancel function to discontinue monitoring.
Combine
Support for Combine is provided by ConnectivityObserver which has the same start and cancel functions as ConnectivityMonitor but it returns AnyPublisher. It can be used to observe path changes.
Demo App
See [Connectivity] for a demo app which runs on macOS and iOS.
Swift Package
This project is set up as a Swift Package which can be used by the [Swift Package Manager] (SPM) with Xcode. In your Package.swift add this package with the code below.
dependencies: [
.package(url: "https://github.com/brennanMKE/ConnectivityKit", from: "1.0.0"),
],Supporting iOS 10.0 and Later
Since this package automatically handles the selection of the implementation your code can just use ConnectivityMonitor to get updates to the network path. The Reachability API comes from the [System Configuration Framework] which is available for all of Apple's platforms except watchOS. The implementation for the ReachabilityMonitor will get an empty implementation for watchOS prior to watchOS 6.0 which is when [Network Framework] was first made available to watchOS.
If your Deployment Target for any of Apple's platforms supports [Network Framework] then it will always use the modern implementation. This package will allow you to use the same code across all platforms and respond to changes to network connectivity.
[Network Framework]: https://developer.apple.com/documentation/network [NWPathMonitor]: https://developer.apple.com/documentation/network/nwpathmonitor [NWPath]: https://developer.apple.com/documentation/network/nwpath [SCNetworkReachability]: https://developer.apple.com/documentation/systemconfiguration/scnetworkreachability-g7d [System Configuration Framework]: https://developer.apple.com/documentation/systemconfiguration [Introduction to Network.framework]: https://developer.apple.com/videos/play/wwdc2018/715 [Swift Package Manager]: https://swift.org/package-manager/ [Connectivity]: https://github.com/brennanMKE/Connectivity
Package Metadata
Repository: AsyncSwiftKits/ConnectivityKit
Stars: 1
Forks: 0
Open issues: 0
Default branch: main
Primary language: objective-c
License: Apache-2.0
README: README.md