ConnectionKage SDK is a lightweight and flexible library for monitoring network reachability and connection status on iOS. This SDK helps developers understand network conditions, connection types, and handle scenarios where the device lacks connectivity.
- Monitor real-time network reachability.
- Identify network connection types (WiFi, Cellular, Ethernet, Loopback, etc.).
- Detect constrained and expensive network conditions.
- Understand the reasons for an unsatisfied network path (e.g., VPN inactive, WiFi disabled).
- Easy integration with a customizable abstraction layer for testing.
To integrate ConnectionKage into your project:
- Open your project in Xcode.
- Navigate to File → Add Packages....
- Enter the repository URL:
https://github.com/Swiftkage/ConnectionKage
. - Choose the appropriate version and click Add Package.
Start by creating an instance of the Reachability
class:
import ConnectionKage
@State var reachability = Reachability()
reachability.startMonitoring()
You can observe network status, connection type, and other properties:
print("Is Reachable: \(reachability.isReachable)")
print("Connection Type: \(reachability.connectionType)")
print("Is Constrained: \(reachability.isConstrained)")
print("Is Expensive: \(reachability.isExpensive)")
if let reason = reachability.disconnectionReason {
print("Disconnection Reason: \(reason)")
}
When monitoring is no longer required, stop the Reachability
monitor to free resources:
reachability.stopMonitoring()