Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Alert user on no wi-fi

Hi
Can anyone assist with the code required to alert the user when trying to call an external URL but no wi-fi signal is available?

So say after a preset time of 10 secs a dialogue box would display to alert the user that a wi-fi connection is required to view the page.

regards
AndyG.

— asked May 20th 2010 by Andrew Gray
  • iphone
  • wi-fi
  • wifi
0 Comments

2 Answers

  • Accepted Answer

    This will detect wifi and 3g

    if (Titanium.Network.online == false)
    {
            var dlg = Titanium.UI.createAlertDialog({
            'title' : 'No Network',
            'message' : 'You are not connected to a network. ',
            'buttonNames' : [ 'OK' ]
        });
        dlg.show();
    Titanium.App.fireEvent('hide_indicator');
    }
    
    — answered May 20th 2010 by Laney Dale
    permalink
    0 Comments
  • Here's a sample

    I haven't tested this but it should work.

    function wifi_alert(){
        if(Ti.Network.NETWORK_WIFI == false){
             alert("You need a WI-FI connection.");
        }
    }
    
    setTimeout(wifi_alert(),10000);
    
    — answered May 20th 2010 by Ryan Gartin
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.