Checking Internet Connection
Posted: Sat Aug 25, 2012 6:40 pm
Hi there dear LiveCoders,
At some certain occasions, my apps crash if there is no internet connection.
Here is my solution to check if there is connection.
Put a blank text file on a server, your website or any other secure location.
In my case, the file is only 13bytes.
Then put this code snippet into your script:
Then,
Is there a better, faster or more secure way to check internet connection on iPhone?
Please, share your ideas.
Regards,
~ Ender Nafi Elekcioglu
At some certain occasions, my apps crash if there is no internet connection.
Here is my solution to check if there is connection.
Put a blank text file on a server, your website or any other secure location.
In my case, the file is only 13bytes.
Then put this code snippet into your script:
Code: Select all
function checkInternetConnection
if the environment is "mobile" then
put "http://www.example.com/checkConnection.txt" into theSource
put specialFolderPath("documents") & "/checkConnection.txt" into theTarget
libUrlDownloadToFile theSource, theTarget
if ((there is a file theTarget) and (calcFileSize(specialFolderPath("documents"), "checkConnection.txt") > 0)) then
delete file theTarget
return true
else
return false
end if
else
return false
end if
end checkInternetConnection
Code: Select all
if checkInternetConnection() then
-- do your stuff here
end if
Please, share your ideas.
Regards,
~ Ender Nafi Elekcioglu