Native approach to monitor network reachability on iOS
There are lots of third party libraries to monitor the network reachability on iOS e.g. ReachabilitySwift, Alamofire etc. All these libraries provide an easy way to integrate in the code. Considering that all of you are already aware of them.
Get Started
Apple has released a new Network.framework in iOS 12. There are lots of apis to deal with the network on iOS. We can check network status and can do network monitoring also by Network.framework.
In this article, I’ll explain that how can I create a network reachability protocol which will monitor network and check network current status. Before that, let’s discuss some apis which will be used to achieve this requirement.
NWPath
An object that contains information about the properties of the network that a connection uses, or that are available to your app.
NWPathMonitor
An observer that you use to monitor and react to network changes.