I have an application that requires an internet connection for a certain library I use (XIMSS for Communigate). It receives status updates from a server and I can't alter the source of the lib. Is there a way to detect that the device disconnected from the internet? I'd like to avoid having to ping a server every x seconds to see if there is still a connection.
Apple's Reachability does this for you. Notifies you as your connectivity changes.
In iOS you can check like that :-
-(BOOL)returnInternetConnectionStatus{
ReachabilityLattest *reach = [ReachabilityLattest reachabilityForInternetConnection];
NetworkStatus internetStatus = [reach currentReachabilityStatus];
if ((internetStatus != NotReachable)) {
return TRUE;
} else {
return FALSE;
}
}
For more detail you can download from here Reachability Sample Code
Hope this helps you !
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With