In my research on iOS App submittal I noticed this:
From: http://developer.apple.com/news/ios/appstoretips/
Don’t Forget to Include Network Error Alerts in Your Code
If your application provides functionality that requires access to a network, it’s very important that your code include a customer alert or notification when the network is not available.
The Reachability sample application demonstrates how to use the System Configuration Reachability API to monitor the network state of an iPhone or iPod touch. Use this sample code to learn how to detect the absence of Wi-Fi and Wireless Wide Area Network (WWAN) services so your application knows when it’s necessary to produce a network error alert.
Your users will appreciate knowing when an application has no network access — and missing “network alerts” is the third most common reason for applications being returned to developers for modification.
Now I did find some code on the Lua site that works fine, to check for the existence of a web file by getting its header, Apache style, as:
-- load the http module
local http = require("socket.http")
local function checkNetwork( passURL )
-- Requests information about a document, without downloading it.
-- resultR is 1, resultC is 200, and resultH would return the following headers:
-- resultCH = {
-- [connection] =\> "close"
-- [content-type] =\> "text/html"
-- [vary] =\> "Accept-Encoding"
-- [date] =\> "Fri, 10 Dec 2010 23:42:39 GMT"
-- [x-powered-by] =\> "PHP/5.2.14"
-- [server] =\> "Apache"
-- }
local resultR, resultC, resultH
resultR, resultC, resultH = http.request {
method = "HEAD",
url = passURL
}
-- resultC contains Apache style HTTP error codes, 200 for success, 404 for page not found, etc.
if ( resultC == 200 ) then
return true
else
AlertMsg = "An internet connection is required for this feature."
native.showAlert( AlertTitle, AlertMsg, { "OK" } )
return false
end
end
So I shut off my iPad’s WiFi and expectedly get the fail message. That kinda works. It didnt know if I had a network connection or not, just that the request failed somehow.
Any buddy have any better way to check for a network connection?
[import]uid: 6114 topic_id: 4386 reply_id: 304386[/import]