|
|
@@ -1114,6 +1114,31 @@ Whether you need to set the `NSExceptionRequiresForwardSecrecy` to `NO` depends
|
|
|
|
|
|
> It is recommended to always use valid certificates in production environments.
|
|
|
|
|
|
+### Network Reachability
|
|
|
+
|
|
|
+The `NetworkReachabilityManager` listens for reachability changes of hosts and addresses for both WWAN and WiFi network interfaces.
|
|
|
+
|
|
|
+```swift
|
|
|
+let manager = NetworkReachabilityManager(host: "www.apple.com")
|
|
|
+
|
|
|
+manager?.listener = { status in
|
|
|
+ print("Network Status Changed: \(status)")
|
|
|
+}
|
|
|
+
|
|
|
+manager?.startListening()
|
|
|
+```
|
|
|
+
|
|
|
+There are some important things to remember when using network reachability to determine what to do next.
|
|
|
+
|
|
|
+* **Do NOT** use Reachability to determine if a network request should be sent.
|
|
|
+ * You should **ALWAYS** send it.
|
|
|
+* When Reachability is restored, use the event to retry failed network requests.
|
|
|
+ * Even though the network requests may still fail, this is a good moment to retry them.
|
|
|
+* The network reachability status can be useful for determining why a network request may have failed.
|
|
|
+ * If a network request fails, it is more useful to tell the user that the network request failed due to being offline rather than a more technical errror, such as "request timed out."
|
|
|
+
|
|
|
+> It is recommended to check out [WWDC 2012 Session 706, "Networking Best Practices"](https://developer.apple.com/videos/play/wwdc2012-706/) for more info.
|
|
|
+
|
|
|
---
|
|
|
|
|
|
## Component Libraries
|