iOS: Check for Internet Connection?

Gerry Orkin gerry.orkin at
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:

 global internetAvailable	

Then on openstack call this:

  iphoneSetReachabilityTarget  ""

Have this in your stack script too:

on reachabilityChanged  hostNameOrAddress, reachabilityInfo
  global internetAvailable
  put reachabilityInfo into internetAvailable
end reachabilityChanged

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:

on internetCheck
        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
            exit internetCheck
            exit internetCheck
          end if
      end switch
end internetCheck

More information about the Use-livecode mailing list