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.
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'); }
-
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);