0

I'm new at iOS code so hopefully this isn't terribly difficult. I have a couple apps using position information that are working. However, I have things set up so the screen data is refreshed each time "LocationsUpdated" occurs. I also have a filter so that inaccurate positions are not used. This works pretty well while moving but if the device is stationary, the accuracy value on screen doesn't get updated until the position changes.

Is there any way to view the RIGHT NOW accuracy of the GPS position even if the position from the last location hasn't changed? I would expect there to be a different keyword than "LocationsUpdated" for something like this but I haven't found one.

Judging from my previous experience with using iOS devices, on the native maps app, even when they're stationary, the accuracy circle continues to resize until it gets a maximum accuracy position. I suspect I can access this for my own code as well.

This is my current code:

public class MyDelegate : CLLocationManagerDelegate
{
   ViewController _parent = null;
   public MyDelegate(ViewController parent)
   {
      _parent = parent;
   }
   public override void LocationsUpdated(CLLocationManager manager, CLLocation[] locations)
   {
      _parent.UpdateLabels(locations[(locations.Length - 1)]);
   }
   public override void UpdatedLocation(CLLocationManager manager, CLLocation newLocation, CLLocation oldLocation)
   {
      _parent.UpdateLabels(newLocation); 
   }
}
Jerry Jeremiah
  • 9,045
  • 2
  • 23
  • 32
Andy Adams
  • 31
  • 4
  • It doesn't sound like a very regular use case, but I guess it isn't impossible to get the job done. Have you tried simply retrieving the location at a specific interval? Doing so can for obvious reasons be battery consuming, which you'd need to keep in mind. – Demitrian Jul 09 '16 at 21:10
  • That could be an option. I could do that only if the accuracy is worse than my desired value. The use case is I want to wait until the position accuracy is high before beginning to move. As of now I don't even know if it's getting close without moving. The next thing is how to retrieve location on command without using LocationsUpdated. – Andy Adams Jul 09 '16 at 21:43
  • Sure. Wouldn't that be sufficient? It could be as simple as setting a flag, say `IsDeviceActive` based on whether or not the device has moved to a new position. This could be set dependent on when the last location update event was fired. Then, if `IsDeviceActive`is `false`, you could ping for the location every x seconds/minutes/hours. By the way, what are you using to retrieve the GPS data? I guess you have read the documentation hereof? – Demitrian Jul 09 '16 at 22:23
  • well clearly I can't figure out how to format code in one of these comments. I've tried both the methods above and they both seem to do the same thing. `LocationsUpdated()` and `UpdatedLocation()` I've tried to make the best sense out of the documentation at xamarin and apple but sometimes making the conversion from apple docs to xamarin is tricky for me and this has got me stuck. – Andy Adams Jul 09 '16 at 22:44
  • Possible duplicate of [CLLocationManager Update frequency](http://stackoverflow.com/questions/8803961/cllocationmanager-update-frequency) – SushiHangover Jul 10 '16 at 00:47
  • 1
    I would look at the accepted answer on the linked duplicate AND the linked answer concerning using NSTimer to request additional location updates in the comments of that answer. – SushiHangover Jul 10 '16 at 00:50
  • Thanks, I will review those suggestions and report back after. – Andy Adams Jul 10 '16 at 23:59

0 Answers0