iOS: Check for Internet Connection?
gerry.orkin at gmail.com
Thu May 22 20:21:30 EDT 2014
There are commands for this. See the dictionary for "iphoneSetReachabilityTarget" and "reachabilityChanged.
This is what I do. Start with this at the top of your stack script:
Then on openstack call this:
Have this in your stack script too:
on reachabilityChanged hostNameOrAddress, reachabilityInfo
put reachabilityInfo into internetAvailable
That keeps a global variable updated with the current status of the connection. When I want to check for the current status I call this:
case internetAvailable is empty
answer "There doesn't appear to be an internet connection. Please try again later."
exit to top
case "reachable" is among the items of internetAvailable and "is cell" is not among the items of internetAvailable
exit internetCheck -- there's an active wifi connection
case internetAvailable contains "is cell"
answer "There's no wifi available. Use mobile data?" With "Yes" or "No"
if it = "Yes" then
-- do whatever you need here
More information about the Use-livecode