从iOS 10开始,应用需要网络许可才能访问网络。
如何以编程方式检查我的应用是否设置为“关闭”或“WLAN”或“WLAN和Celluar数据”?
Screenshot of "Allow App TO USE DATA"
最佳答案
您可以使用可达性进行检查。
Reachability *netReachability = [Reachability reachabilityForInternetConnection];
[netReachability startNotifier];
NetworkStatus networkStatus = [netReachability currentReachabilityStatus];
if(networkStatus == NotReachable)
{
//No internet connection.
}
else if (networkStatus == ReachableViaWiFi)
{
//connected with WiFi network.
}
else if (networkStatus == ReachableViaWWAN)
{
//connected with 3G network.
}
希望这可以帮助。