iOS: Check for Internet Connection?

Rick Harrison harrison at all-auctions.com
Thu May 22 23:30:18 EDT 2014


Hi Colin & Gerry,

This is exactly what I need!

iPhoneSetReachabilityTarget,
is a little obscure to search for
though isn’t it?  Why didn’t they
name it iPhoneCheckForInternetConnection?  LOL

Thanks!

Rick

On May 22, 2014, at 8:21 PM, Gerry Orkin <gerry.orkin at gmail.com> wrote:

> 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  "google.com"
> 
> 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
> switch
>        case internetAvailable is empty
>          answer "There doesn't appear to be an internet connection. Please try again later."
>          exit to top
>          break
> 
>        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
>          break
> 
>        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
>          else
>            exit internetCheck
>          end if
>          break
>      end switch
> end internetCheck
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode






More information about the Use-livecode mailing list