/// <summary> /// Stop listening /// </summary> public Task <bool> StopListeningAsync() { if (!isListening) { return(Task.FromResult(true)); } isListening = false; #if __IOS__ if (CLLocationManager.HeadingAvailable) { manager.StopUpdatingHeading(); } // it looks like deferred location updates can apply to the standard service or significant change service. disallow deferral in either case. if ((listenerSettings?.DeferLocationUpdates ?? false) && CanDeferLocationUpdate) { manager.DisallowDeferredLocationUpdates(); } #endif if (listenerSettings?.ListenForSignificantChanges ?? false) { manager.StopMonitoringSignificantLocationChanges(); } else { manager.StopUpdatingLocation(); } listenerSettings = null; position = null; return(Task.FromResult(true)); }
private void SetDeferrment() { if (ReportInterval == 1000 && MovementThreshold > 0) { #if __IOS__ _manager.DisallowDeferredLocationUpdates(); #endif if (MovementThreshold > 0) { _manager.DistanceFilter = MovementThreshold; } else { _manager.DistanceFilter = CLLocationDistance.FilterNone; } } else { if (!isDeferred #if __IOS__ && _manager.AllowsBackgroundLocationUpdates #endif ) { _manager.DistanceFilter = CLLocationDistance.FilterNone; double dist = MovementThreshold == 0.0 ? CLLocationDistance.MaxDistance : MovementThreshold; #if __IOS__ _manager.AllowDeferredLocationUpdatesUntil(dist, ReportInterval / 1000); #endif isDeferred = true; } } }
public iOSGPSAdapter( CLLocationManager locationManager, int gpsTimeoutInMs = 30000, float desiredAccuracyInMeters = 50) { _locationManager = locationManager; _locationManager.PausesLocationUpdatesAutomatically = false; _locationManager.DesiredAccuracy = CLLocation.AccuracyBest; _locationManager.ActivityType = CLActivityType.Other; _locationManager.DistanceFilter = CLLocationDistance.FilterNone; _locationManager.DisallowDeferredLocationUpdates(); _timeoutInMs = gpsTimeoutInMs; _desiredAccuracyInMeters = desiredAccuracyInMeters; }
public static Task <bool> StopTracking() { if (!IsTracking || Manager == null) { return(Task.FromResult(result: true)); } IsTracking = false; if (CanDeferLocationUpdate) { Manager.DisallowDeferredLocationUpdates(); } Manager.StopMonitoringSignificantLocationChanges(); Manager.StopUpdatingLocation(); return(Task.FromResult(result: true)); }
private void ApplyCoreLocationProfile(CoreLocationProfile profile) { _clManager.DesiredAccuracy = profile.DesiredAccuracy; _clManager.DistanceFilter = profile.DistanceFilter; _clManager.AllowsBackgroundLocationUpdates = profile.AllowBackgroundLocationUpdates; _clManager.PausesLocationUpdatesAutomatically = profile.PauseLocationUpdatesAutomatically; //if (profile.MonitorSignificantChanges) //{ // _clManager.StartMonitoringSignificantLocationChanges(); //} //else //{ // _clManager.StopMonitoringSignificantLocationChanges(); //} if (_locationsDeferred && !profile.AllowDeferredLocationUpdates) { _clManager.DisallowDeferredLocationUpdates(); _locationsDeferred = false; } }