Sponser Link

How to check internet connection in iOS and Android using Xamarin in C Sharp

Go to MainPage.xaml.cs

Declare name space of Xamarin

using Xamarin.Forms;

using Xamarin.Essentials;

Write the given below function. This function will return the state of internet connection.

   private bool CheckInternet_connection()

        {

            var current = Connectivity.NetworkAccess;

            if (current == NetworkAccess.Internet)

            {

                // Connection to internet is available

                return true;

            }

            else

            {

                return false;

            }

        }