Class for checking network reachability via WiFi / WWAN (Cellular)
Inheritance: IDisposable
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            _reachability = new Reachability("www.google.co.uk");
            _reachability.ReachabilityUpdated += HandleReachabilityUpdated;
        }
 public NetworkTester_iOS()
 {
     _reachability = new Reachability.Reachability("www.starstable.com");
     _reachability.ReachabilityUpdated += OnReachabilityUpdated;
     
     Ready = false;
 }
Example #3
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            summaryLabel.Hidden = true;

            // Change the host name here to change the server you want to monitor.
            const string remoteHostName = "www.google.com";

            remoteHostLabel.Text = $"Remote Host: {remoteHostName}";

            hostReachability = Reachability.ReachabilityWithHostName(remoteHostName);
            hostReachability.StartNotifier();
            UpdateInterfaceWithReachability(hostReachability);

            internetReachability = Reachability.ReachabilityForInternetConnection();
            internetReachability.StartNotifier();
            UpdateInterfaceWithReachability(internetReachability);
        }
Example #4
0
        private void ConfigureTextField(UITextField textField, UIImageView imageView, Reachability reachability)
        {
            var networkStatus      = reachability.CurrentReachabilityStatus();
            var connectionRequired = reachability.ConnectionRequired();
            var statusString       = string.Empty;

            switch (networkStatus)
            {
            case NetworkStatus.NotReachable:
                statusString    = "Access Not Available";
                imageView.Image = UIImage.FromBundle("stop-32.png");
                // Minor interface detail - connectionRequired may return YES even when the host is unreachable. We cover that up here...
                connectionRequired = false;
                break;

            case NetworkStatus.ReachableViaWWAN:
                statusString    = "Reachable WWAN";
                imageView.Image = UIImage.FromBundle("WWAN5.png");
                break;

            case NetworkStatus.ReachableViaWiFi:
                statusString    = "Reachable WiFi";
                imageView.Image = UIImage.FromBundle("Airport.png");
                break;
            }

            if (connectionRequired)
            {
                statusString = $"{statusString}, Connection Required";
            }

            textField.Text = statusString;
        }