AFNetworkReachabilityManager *manager = [AFNetworkReachabilityManager sharedManager];
[manager setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
switch (status) {
case AFNetworkReachabilityStatusUnknown:
{
UIAlertController *ac = [UIAlertController alertControllerWithTitle:@"ESports" message:@"未识别的网络" preferredStyle:UIAlertControllerStyleAlert];
[ac addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleCancel handler:nil]];
break;
}
case AFNetworkReachabilityStatusNotReachable:
{
UIAlertController *ac = [UIAlertController alertControllerWithTitle:@"ESports" message:@"未连接" preferredStyle:UIAlertControllerStyleAlert];
[ac addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleCancel handler:nil]];
break;
}
case AFNetworkReachabilityStatusReachableViaWWAN:
{
UIAlertController *ac = [UIAlertController alertControllerWithTitle:@"ESports" message:@"您确定要使用移动网络?" preferredStyle:UIAlertControllerStyleAlert];
[ac addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleCancel handler:nil]];
break;
}
case AFNetworkReachabilityStatusReachableViaWiFi:
{
UIAlertController *ac = [UIAlertController alertControllerWithTitle:@"ESports" message:@"WiFi环境" preferredStyle:UIAlertControllerStyleAlert];
[ac addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleCancel handler:nil]];
break;
}
default:
break;
}
}];
// 开始监听
[manager startMonitoring];
网友评论