Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

Permission to use location iOS - Forms

$
0
0

I'm using Xamarin.Forms and creating an iOS App who has a background service to get a location each 10 minutes.

The code is working, my problem is when I access the App configuration on an IPad. It shows the permission for accesss the camera but not to access the current location.

I think that will be a problem when I submit the App for review.

For initialize the location:

this.locMgr = new CLLocationManager();
if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0))
{
locMgr.RequestAlwaysAuthorization(); // works in background
//locMgr.RequestWhenInUseAuthorization (); // only in foreground
}

For getting the location:

if (CLLocationManager.LocationServicesEnabled)
{
if (CLLocationManager.Status==CLAuthorizationStatus.Authorized || CLLocationManager.Status==CLAuthorizationStatus.AuthorizedAlways)
{
//set the desired accuracy, in meters
LocMgr.DesiredAccuracy = 1;
LocMgr.LocationsUpdated += (object sender, CLLocationsUpdatedEventArgs e) =>
{
_currentLocation = (e.Locations[e.Locations.Length - 1]);
};

    LocMgr.AuthorizationChanged += (object sender, CLAuthorizationChangedEventArgs e) =>
    {
        if (e.Status == CLAuthorizationStatus.Denied || e.Status == CLAuthorizationStatus.Restricted)
        {
            LocMgr.StopUpdatingLocation();
            _currentLocation = null;
        }
    };

    LocMgr.StartUpdatingLocation();
}

}

There are something that I forgot?

Thanks.


Viewing all articles
Browse latest Browse all 58056

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>