I am working on an application that needs a VPN connection to synchronize data. I use the reachability class to check host availability.
@ Functionality: - When the application is connected to the VPN through the Junos Pulse application, data synchronization should continue, if the VPN connection is lost, it should display an Alert message. Now it works for the scenario below.
@Working scenario: - The VPN is connected initially, I completed the synchronization and then disconnected the VPN manually from Junos Pulse. Now I'm trying to sync again, this throws a warning, which is expected.
@Problem Scenarion: - I first synchronized and left the application inactive to automatically disable the VPN. Now, after the VPN transition, I'm trying to sync again. This is not due to the warning that the VPN is not there. It tries to synchronize and fails because the server is unavailable without a VPN.
I am exhausted by finding a solution on the Internet. I am inserting a piece of code here. Any suggestion is much appreciated.
-(BOOL)checkHostAvailability { Reachability *objReach = [Reachability reachabilityWithHostName:[self hostServer]]; NetworkStatus hostAvailability = [objReach currentReachabilityStatus]; if(hostAvailability == ReachableViaWiFi || hostAvailability == ReachableViaWWAN) { RLog(@"Host is Reachable"); return YES; } return NO; }
source share