Modern networking support to monitor network connectivity

Overview

ConnectivityKit

Adapting to changes in network connectivity can allow for suspending or resuming network activity. When entering an elevator or going through a tunnel our devices typically lose connectivity completely. We also move out of range of WiFi and transition to a cellular connection. Apple's Network Framework includes NWPathMonitor which provides updates in response to changes to NWPath. This framework was introduced in 2018 and is a modern replacement to SCNetworkReachability, simply known as the Reachability API which does not support many of the features supported by modern network protocols such as WiFi 6 and 5G.

For apps which still support older OS versions it is necessary to use Reachability while most users are able to use the Network framework. This package automatically users the API which is available based on the OS version.

See: Introduction to Network.framework

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.

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.


You might also like...
Easy HTTP Networking in Swift a NSURLSession wrapper with image caching support
Easy HTTP Networking in Swift a NSURLSession wrapper with image caching support

Networking was born out of the necessity of having a simple networking library that doesn't have crazy programming abstractions or uses the latest rea

Baby Monitor iOS

Baby Monitor iOS Welcome to the Baby Monitor project. It's an application made for monitoring babies, which can help parents take care of their childr

Elegant HTTP Networking in Swift
Elegant HTTP Networking in Swift

Alamofire is an HTTP networking library written in Swift. Features Component Libraries Requirements Migration Guides Communication Installation Usage

Type-safe networking abstraction layer that associates request type with response type.

APIKit APIKit is a type-safe networking abstraction layer that associates request type with response type. // SearchRepositoriesRequest conforms to Re

Robust Swift networking for web APIs
Robust Swift networking for web APIs

Conduit Conduit is a session-based Swift HTTP networking and auth library. Within each session, requests are sent through a serial pipeline before bei

Lightweight Concurrent Networking Framework
Lightweight Concurrent Networking Framework

Dots Example To run the example project, clone the repo, and run pod install from the Example directory first. Requirements iOS 8.0+ / macOS 10.10+ /

Versatile HTTP Networking in Swift
Versatile HTTP Networking in Swift

Net is a versatile HTTP networking library written in Swift. 🌟 Features URL / JSON / Property List Parameter Encoding Upload File / Data / Stream / M

A type-safe, high-level networking solution for Swift apps
A type-safe, high-level networking solution for Swift apps

What Type-safe network calls made easy Netswift offers an easy way to perform network calls in a structured and type-safe way. Why Networking in Swift

🏇 A Swift HTTP / HTTPS networking library just incidentally execute on machines
🏇 A Swift HTTP / HTTPS networking library just incidentally execute on machines

Thus, programs must be written for people to read, and only incidentally for machines to execute. Harold Abelson, "Structure and Interpretation of Com

Releases(1.1.0)
Owner
Brennan Stehling
iOS Engineer, Objective-C and Swift
Brennan Stehling
iOS Network monitor/interceptor framework written in Swift

NetShears NetShears is a Network interceptor framework written in Swift. NetShears adds a Request interceptor mechanisms to be able to modify the HTTP

Divar 119 Dec 21, 2022
🌏 A zero-dependency networking solution for building modern and secure iOS, watchOS, macOS and tvOS applications.

A zero-dependency networking solution for building modern and secure iOS, watchOS, macOS and tvOS applications. ?? TermiNetwork was tested in a produc

Bill Panagiotopoulos 90 Dec 17, 2022
🌐 Makes Internet connectivity detection more robust by detecting Wi-Fi networks without Internet access.

Connectivity is a wrapper for Apple's Reachability providing a reliable measure of whether Internet connectivity is available where Reachability alone

Ross Butler 1.6k Dec 30, 2022
An open-source Swift framework for building event-driven, zero-config Multipeer Connectivity apps

PeerKit An open-source Swift framework for building event-driven, zero-config Multipeer Connectivity apps Usage // Automatically detect and attach to

JP Simard 861 Dec 23, 2022
Control apps' wireless connectivity policy

AirKeeper This tweak replicates a feature in Chinese iPhone model by using Apple's own private APIs, which effectively writes to /var/preferences/com.

udevs 15 Dec 22, 2022
Another network wrapper for URLSession. Built to be simple, small and easy to create tests at the network layer of your application.

Another network wrapper for URLSession. Built to be simple, small and easy to create tests at the network layer of your application. Install Carthage

Ronan Rodrigo Nunes 89 Dec 26, 2022
A network extension app to block a user input URI. Meant as a network extension filter proof of concept.

URIBlockNE A network extension app to block a user input URI. Meant as a network extension filter proof of concept. This is just a research effort to

Charles Edge 5 Oct 17, 2022
Say goodbye to the Fat ugly singleton Network Manager with this Network Layer

MHNetwork Protocol Oriented Network Layer Aim to avoid having bloated singleton NetworkManager Philosophy the main philosophy behind MHNetwork is to h

Mohamed Emad Hegab 19 Nov 19, 2022
NWReachability - a pure Swift library for monitoring the network connection of iOS devices using Apple's Network framework.

NWReachability is a pure Swift library for monitoring the network connection of iOS devices using Apple's Network framework.

null 4 Dec 2, 2022
Easy and lightweight network layer for creating different set of network requests like GET, POST, PUT, DELETE customizable with coders conforming to TopLevelDecoder, TopLevelEncoder

Easy and lightweight network layer for creating different set of network requests like GET, POST, PUT, DELETE customizable with coders conforming to TopLevelDecoder, TopLevelEncoder

Igor 2 Sep 16, 2022