如何检查iPhone上的wifi服务,在我的应用程序中使用wifi导航

时间:2014-08-21 05:13:56

标签: ios service wifi

我可以查看wifi服务的状态吗?如果用户手机未连接到WiFi,则启用还是禁用。我需要它来创建用户警报,因为我需要WIFi状态为“ON”状态我的应用程序导航。

enter image description here

3 个答案:

答案 0 :(得分:1)

为此,您需要在项目中导入可达性类。

BOOL isConnectedProperly = ([[Reachability reachabilityForInternetConnection] currentReachabilityStatus] == ReachableViaWiFi);

价: https://developer.apple.com/library/ios/samplecode/Reachability/Introduction/Intro.html

https://github.com/tonymillion/Reachability

答案 1 :(得分:0)

Use Reachability Class for checking the network connection state


Reachability *internetReachable=[Reachability reachabilityForInternetConnection];    
if(internetReachable.currentReachabilityStatus == ReachableViaWiFi)
{
    wifiAvailable=YES;
}
else
{
// Show the alert to turn on wifi
}

答案 2 :(得分:0)

使用代码apple提供https://developer.apple.com/iphone/library/samplecode/Reachability

Reachability *reachability = [Reachability reachabilityForInternetConnection];
[reachability startNotifier];

NetworkStatus status = [reachability currentReachabilityStatus];

if(status == NotReachable) 
{
    //No internet
}
else if (status == ReachableViaWiFi)
{
    //WiFi
}
else if (status == ReachableViaWWAN) 
{
    //3G
}