TCustomNetworkState =
class
(TObject)
function
GetSSID:
String
; virtual; abstract;
function
IsConnected:
Boolean
; virtual; abstract;
function
IsWifiConnected:
Boolean
; virtual; abstract;
function
IsMobileConnected:
Boolean
; virtual; abstract;
end
;
You can also use some code like this from Daniel Magin as a backup if you need to (put your own domain place of google.com):
function CheckInternet: boolean;
begin
result:=false;
try
IdTCPClient1.ReadTimeout:=2000;
IdTCPClient1.ConnectTimeout:=2000;
IdTCPClient1.Port:=80;
IdTCPClient1.Host:=’google.com’;
IdTCPClient1.Connect;
IdTCPClient1.Disconnect;
result:=true;
except
result:=false;
end;
end;
Update: Apparently on IOS you should never do synchronous network calls (including this check connectivity functionality) in the main thread. We’ve run into problems with this on iPad Air devices. One recommendation is to place this connectivity check in an anonymous background thread.