开发者

NetworkReachability in Monotouch returns a false positive

I'm trying to test NetworkReachabil开发者_如何学City in the AppDelegate.FinishedLaunching method of my app (invoking on the main thread so I dont hit the 20 sec timeout).

The problem I'm up against is that the test is always returning "false" (i.e. network is not available), even although this is not the case. I'm running in the iPhone Simulator, and if I let my app run on a bit further, I can access the network with no problem.

I've read elsewhere that there appears to be a known bug in Apple's Reachability code. I wondered if anyone has come across this issue, and perhaps found a workaround?

Thanks in advance,

Mark


I do this:

bool status = Reachability.InternetConnectionStatus() != NetworkStatus.NotReachable && Reachability.IsHostReachable("google.com");

You can replace google.com with whatever the domain your api is located at. I was getting false positives myself because I was originally putting in the whole link like "http://google.com" ...It would return false on those...Once I removed the http and just had the domain, it started working.

I should note I am using the Reachability class by Miguel de Icaza

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜