Forum Xamarin.iOS

Track location. CLLocationManager AllowDeferredLocationUpdatesUntil(distance, time) not working.

_DK__DK_ DEMember ✭✭

Location update is made every second, no matter what time I give. What am I doing wrong?

protected CLLocationManager locMgr = new CLLocationManager();
       locMgr.AllowsBackgroundLocationUpdates = true;

       partial void BtnLocation_TouchUpInside(UIButton sender)
        {
      if (CLLocationManager.LocationServicesEnabled)
            {
                LocMgr.Delegate = new MyLocationDelegate();
                LocMgr.DesiredAccuracy = CLLocation.AccuracyBest;
                LocMgr.DistanceFilter = CLLocationDistance.FilterNone; 
                LocMgr.AllowsBackgroundLocationUpdates = true;
                LocMgr.AllowDeferredLocationUpdatesUntil(100, 30);  
                LocMgr.StartUpdatingLocation();  
            }
         }


       public class MyLocationDelegate : CLLocationManagerDelegate
        {
          public override void LocationsUpdated(CLLocationManager manager, CLLocation[] locations)
           {      
            foreach (var loc in locations)
             {    
               //do something                                                
             }
           } 
         }        
Tagged:

Posts

Sign In or Register to comment.