Press ESC to close

Xamarin Internet Control

You may want to have internet in your projects. In general, the internet is not very simple. That’s why you need to check if the user has internet access. Xamarin makes it easy for us to do this control.

We can click on the right button of your project and select Manage Nuget Packages for Solutions. we need to search the Xam.Plugn.Connectivity plugin in the browse section. After you have installed this package on all our projects, we will check if there is a very simple code with your internetwork. If there is no internet we will give an error message.

After installing the package, we create a variable named isConnected. This variable tells what the CrossConnectivity class is like. If there is internet on this site, we will encode it as Connected variable will be true, if not, it will be false. If the variable is false then we will give an error message if there is no internationalization. I then rotate the return and end the function.

// İnternete bağlı olup olmadığını kontrol ediyoruz
        private void InternetKontrol()
            var isConnected = CrossConnectivity.Current.IsConnected;
            if (isConnected==false)
                DisplayAlert("HATA", "Internet bağlantınız bulunmamaktadır. Lütfen Kontrol edniniz.", "OK");

If you do not have internet, you can open the settings section directly after giving the error message.

Leave a Reply

Your email address will not be published. Required fields are marked *