domaven / xamarin-plugins

Cross platform Xamarin & Windows plugins for PCLs
MIT License
37 stars 51 forks source link

Android 7.1.1 Location Services error #36

Open robintschroeder opened 6 years ago

robintschroeder commented 6 years ago

I have implemented the Geofence plugin into my Xamarin.Forms app as specified. Works great in iOS. Works great on my Android KitKat device.

On my Android 7.1.1 device, I get the following error:

CrossGeofence - You need to enabled Location Services

I am using James' Plugin.Permissions v 2.1.0 - https://github.com/jamesmontemagno/PermissionsPlugin

I did something like this to verify:

private async Task CheckPermissions()
        {
            var results = await CrossPermissions.Current.RequestPermissionsAsync(Permission.LocationAlways);
            PermissionStatus status = results[Permission.LocationAlways];
            if (status != PermissionStatus.Granted) //<-- this is always TRUE
            {
                //we have already checked location permissions
                CrossGeofence.RequestLocationPermission = true;
            }
            else
            {
                CrossGeofence.RequestLocationPermission = false;
            }
            CrossGeofence.GeofencePriority = GeofencePriority.HighAccuracy;

            CrossGeofence.Current.IsLocationEnabled((bool locationIsEnabled) =>
            {
                if (locationIsEnabled) //<-- this is always FALSE
                { }
            });
        }

Anyone have any ideas?

Westat-Transportation commented 5 years ago

We submitted a couple pull requests that address this and the authors of this package released a new plugin that incorporate them. Try https://www.nuget.org/packages/Plugin.Geofence/, it is almost a complete drop in replacement with the exception of a namespace change and can be used in projects targeting API 27.