With the mobile network upgrade: 2G->3G->4G even the development of 5G, the network speed is more and more fast, but this flow is like flowing water generally rushing away.
Online is not a joke: sleep forgot to close the flow, the next day the house will be moved!
This is an exaggeration to say, but as a good app developer, we need to give the most appropriate hints in the app.
Give some hints when you need to spend a lot of traffic (for example: video, downloads, etc.).
When users switch the network during user video, give the prompt to continue watching!
The following author gives a real-time monitoring of the network status change Method!
I use the network to spread the widest network monitoring class: Reachability
Click here to download this demo: Click to download
Unzip the files downloaded above and add the Networkreachability folder to the project you need to add.
Example Description: This example demonstrates how to use the Systemconfiguratio Reachalility program interface to determine the associated network connection status and state transformation , so using the reachability in this example . (h/m) file in its own project is premised on the need to introduce systemconfiguration.framework.
Import header file:
#import "NetworkReachability.h"
Defining Global Variables
Networkreachability *_netreachability;
Initialize a variable and assign a value to the agent
_netreachability = [[Networkreachability alloc] init]; _netreachability.delegate = self;
Implementation of the Agent
#pragma mark-networkreachability delegate-(void) reachable: (NetworkStatus) netstatus { switch (netstatus) { Case notreachable: NSLog (@ "No network!"); break; Case Reachableviawifi: NSLog (@ "WiFi"); break; Case Reachableviawwan: NSLog (@ "3G"); break; Default: Break ; }}
Of course, don't forget the proxy statement:
<NetworkReachabilityDelegate>
over!
IOS Monitoring Network changes