Detect a captive portal on iOS
<p>So I'm able to detect whether or not the user has basic internet connection fine using Apple's reachability class. However, when I try to detect whether or not they are connected to a Wi-Fi network that utilizes a captive portal, I get back <code>NetworkStatusReachableViaWiFi</code>, which makes sense. However, this will also be returned if the user is simply using a WiFi connection.</p>

<p>I need to be able to detect both no internet connection and the captive portal situation, as that is effectively no internet.</p>

<p>Are there any reliable API's that can accomplish this task? Based off this article, <a href="http://blog.erratasec.com/2010/09/apples-secret-wispr-request.html#.VxkmrJMrIy5" rel="nofollow">http://blog.erratasec.com/2010/09/apples-secret-wispr-request.html#.VxkmrJMrIy5</a>, Apple pings an internal address when you connect to WiFi to check for a captive portal. I'd prefer to avoid pinging any outside networks, however if I must, does anyone know how I could ping the same Apple address and use the response to tell if my user has a captive portal up?</p>

<p>Edit: I've come across <code>NSURLConnectionDelegate</code> and its method <code>connection:willSendRequestForAuthenticationChallenge:</code>. I think this method may be able to do what I need, I can send a basic request to www.google.com and make myself the delegate, and if this method gets hit do what I need to do. I think I would then be able to call <code>cancelAuthenticanChallenge:</code> </p>

<p>Has anyone ever used this method before to detect a captive portal? How did it work?</p>