I am using Xamarin.Forms and working with a project that will run in Android and Iphone. My project structure (if that information is useful?) are three projects "MyApp", "MyApp.Android" and "MyApp.iOS" inside the same solution.
Right now I am using different plugins such as Xam.Plugin.Geolocator and Plugin.Geofencing.Eddy in order to use Geofencing, but I am facing some problems (as stated in this other question Geofence for xamarin crossplatform).
Right now I want to check if the geofence will be able to work, checking if GPS_PROVIDER and NETWORK_PROVIDER are available, how could I achieve that? Right now I only can check if Location is enabled, but not which provider.
public bool IsLocationAvailable()
{
if (!CrossGeolocator.IsSupported)
return false;
if (!CrossGeolocator.Current.IsGeolocationEnabled)
return false;
if (!CrossGeolocator.Current.IsGeolocationAvailable)
return false;
if (!CrossGeofencing.IsSupported)
return false;
return true;
}
Right now if location provider is set to "GPS only" it throwns an error because of this, but I am not sure how to catch it and handle it. I have seen some other examples and questions but are exclusively for android and I am not sure how to implement those if I am already using those plugins and working mainly on the xamarin forms project (aka "MyApp") instead of the android one ("MyApp.Android")
Sorry for the big image, I am not sure how to resize it!