//read http://iosapi.xamarin.com/?link=T%3aSystemConfiguration.NetworkReachability private NetworkStatus CheckConnectivitiy() { reachability = new SystemConfiguration.NetworkReachability(IPAddress.Parse("0.0.0.0")); NetworkReachabilityFlags flags; bool reachable = reachability.TryGetFlags(out flags); reachability.SetNotification(NetworkChangeDelegate); reachability.Schedule(CFRunLoop.Current, CFRunLoop.ModeDefault); if (reachable) return NetworkStatusHelper(flags); else return NetworkStatus.NotReachable; }
private bool IsNetworkAvailable(out NetworkReachabilityFlags flags) { if (defaultRouteReachability == null) { defaultRouteReachability = new NetworkReachability(new IPAddress(0)); // defaultRouteReachability.SetCallback(OnChange); defaultRouteReachability.Schedule(CFRunLoop.Current, CFRunLoop.ModeDefault); } if (!defaultRouteReachability.TryGetFlags(out flags)) { return(false); } return(IsReachableWithoutRequiringConnection(flags)); }
//read http://iosapi.xamarin.com/?link=T%3aSystemConfiguration.NetworkReachability private NetworkStatus CheckConnectivitiy() { reachability = new SystemConfiguration.NetworkReachability(IPAddress.Parse("0.0.0.0")); NetworkReachabilityFlags flags; bool reachable = reachability.TryGetFlags(out flags); reachability.SetNotification(NetworkChangeDelegate); reachability.Schedule(CFRunLoop.Current, CFRunLoop.ModeDefault); if (reachable) { return(NetworkStatusHelper(flags)); } else { return(NetworkStatus.NotReachable); } }