How can I check if Internet is available in Xamarin forms shared project.
We can use Cross connectivity plugin in PCL project, can we use the same plugin in shared project as well?
How can I check if Internet is available in Xamarin forms shared project.
We can use Cross connectivity plugin in PCL project, can we use the same plugin in shared project as well?
The Cross Connectivity Plugin has been deprecated in favor of Xamarin.Essentials.
First, add the Xamarin.Essentials NuGet Package to both the iOS project and Android project.
Then use it to check connectivity in the shared project:
var current = Connectivity.NetworkAccess;
if (current == NetworkAccess.Internet)
{
// Connection to internet is available
}
I created a Property which returns CrossConnectivity.Current.IsConnected
in its getter.
Also using the Plugin.Connectivity.CrossConnectivity
NuGet Package.