locked
Internet connection RRS feed

  • Question

  • User261931 posted

    hey,

    how can i understand that user have active internet connection. I have an app that user need internet connection everytime. I need your help guys ASAP

    Saturday, May 27, 2017 10:38 PM

Answers

  • User244003 posted

    Hii @Awdos

    Step1: First, you need to add these two packages Xam.Plugin.Connectivity , plugin.wifiinfo in all platforms Step2: Create one class in PCL. NetworkCheck.cs public static bool IsNetworkConnected () { bool retVal = false;

            try {
                retVal = CrossConnectivity.Current.IsConnected;
                return retVal;
            } catch (Exception ex) {
                System.Diagnostics.Debug.WriteLine (ex.Message);
                throw ex;
            }
        }
    

    Step3: In your pages use like below if (CheckNetworkAccess.IsNetworkConnected ()) { Navigation.PushAsync (new HomePage ()); } else { await DisplayAlert ("Your app name", "Please check your network connection", "OK"); }

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Sunday, May 28, 2017 3:57 AM