检测我的应用的iOS网络权限

时间:2016-12-20 06:20:04

标签: ios networking permissions

自iOS 10起,应用程序需要网络权限才能访问网络 如何以编程方式检查我的应用是否设置为“关”或“WLAN”或“WLAN& Celluar数据”?

Screenshot of "Allow App TO USE DATA"

1 个答案:

答案 0 :(得分:0)

您可以使用Reachability进行检查。

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.
}

希望这有帮助。