Location service not longer working

ignaciomachinignaciomachin USMember ✭✭

Hi,

I have this code that just to work fine to get location updates, then from a time being, the code is not working, the LocationsUpdated method is never called.

The CLLocationManager.Status property has a value of "Not Determined" even after I went to Settings/Privacy and enabled the location service for my app.

Not sure where to look next, any ideas?

Thank,
Ignacio

Code:

    LocationManager = new CLLocationManager ();

    public void AddLocationToOrder (Order order)
    {
        LocationManager.Delegate = new LocationDelegate (order);
        LocationManager.StartUpdatingLocation ();
    }

    private class LocationDelegate : CLLocationManagerDelegate
    {
        Order order;
        InvoicePayment payment;

        public LocationDelegate (Order order) : base()
        {
            this.order = order;
        }

        public LocationDelegate (InvoicePayment payment) : base()
        {
            this.payment = payment;
        }

        public override void LocationsUpdated (CLLocationManager manager, CLLocation[] locations)
        {
            if (locations.Length > 0) {
                CLLocation current = locations[ locations.Length-1];
                if (current!=null){
                    if (order != null) {
                        order.Latitude = current.Coordinate.Latitude;
                        order.Longitude = current.Coordinate.Longitude;
                    } 
                    AppDelegate.Current.Manager.LocationManager.StopUpdatingLocation ();
                }
            }
        }
    }

Best Answer

Answers

Sign In or Register to comment.