Quick Tip #3 – Checking for Internet Connectivity

How do we get to know whether the app has internet connectivity? This is important when you want to check for connectivity before doing a server sync.

 public static bool IsInternetAvailable
 {
   get
    {
     var profiles = NetworkInformation.GetConnectionProfiles();
     var internetProfile = NetworkInformation.GetInternetConnectionProfile();
     return profiles.Any(s => s.GetNetworkConnectivityLevel() == NetworkConnectivityLevel.InternetAccess) || (internetProfile != null && internetProfile.GetNetworkConnectivityLevel() == NetworkConnectivityLevel.InternetAccess);
    }
 }

May the code be with you! 😀

logosmall