public bool UpdateLocation(int timeout) { bool result = false; if (_manager != null) { DateTime lastTime = DateTime.Now; while (lastTime.AddSeconds(timeout) > DateTime.Now) { CLLocation location = _manager.Location; if (location != null) { DateTime time = DateTime.SpecifyKind(location.Timestamp, DateTimeKind.Unspecified); if (DateTime.UtcNow < time.AddMinutes(5)) { _currentLocation = new GpsCoordinate(location.Coordinate.Latitude, location.Coordinate.Longitude, time); result = true; break; } } } } return result; }
private bool Start() { if (_manager != null && !_trackingStarted) { _currentLocation = new GpsCoordinate(); if (new Version(UIDevice.CurrentDevice.SystemVersion).Major > 7) _manager.RequestAlwaysAuthorization(); _manager.StartUpdatingLocation(); _trackingStarted = true; return true; } return false; }