来自可达性.m
if ((flags & kSCNetworkReachabilityFlagsConnectionRequired) == 0)
{
// if target host is reachable and no connection is required
// then we'll assume (for now) that your on Wi-Fi
retVal = ReachableViaWiFi;
}
...
- (BOOL) connectionRequired;
{
NSAssert(reachabilityRef != NULL, @"connectionRequired called with NULL reachabilityRef");
SCNetworkReachabilityFlags flags;
if (SCNetworkReachabilityGetFlags(reachabilityRef, &flags))
{
return (flags & kSCNetworkReachabilityFlagsConnectionRequired);
}
return NO;
}
来自 AppDelegate.m
if(connectionRequired)
{
baseLabel= @"Cellular data network is available.\n Internet traffic will be routed through it after a connection is established.";
}
else
{
baseLabel= @"Cellular data network is active.\n Internet traffic will be routed through it.";
}
所以它粗略地说明了设备是使用 Wi-Fi 还是 3G 以及连接是否处于活动状态或设备是否会建立连接。如果用户使用 VPN,设备会要求他先建立 VPN 连接。