From 96986d0c609421cbe4dd26e05621c70a63df076f Mon Sep 17 00:00:00 2001 From: Rohit Vipin Mathews Date: Mon, 3 Jun 2019 12:49:20 +0530 Subject: [PATCH] Disable showing of location calibration on iOS In some devices, the location calibration is shown every time you request the current location. --- .../GeolocationSingleUpdateDelegate.apple.cs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/Geolocator.Plugin/Apple/GeolocationSingleUpdateDelegate.apple.cs b/src/Geolocator.Plugin/Apple/GeolocationSingleUpdateDelegate.apple.cs index a2b58c9..361cbf9 100644 --- a/src/Geolocator.Plugin/Apple/GeolocationSingleUpdateDelegate.apple.cs +++ b/src/Geolocator.Plugin/Apple/GeolocationSingleUpdateDelegate.apple.cs @@ -47,6 +47,14 @@ public GeolocationSingleUpdateDelegate(CLLocationManager manager, double desired t.Dispose(); }, null, timeout, 0); } + +#if __IOS__ + manager.ShouldDisplayHeadingCalibration += (CLLocationManager locationManager) => + { + locationManager.DismissHeadingCalibrationDisplay(); + return false; + }; +#endif cancelToken.Register(() => { @@ -57,7 +65,6 @@ public GeolocationSingleUpdateDelegate(CLLocationManager manager, double desired public Task Task => tcs?.Task; - public override void AuthorizationChanged(CLLocationManager manager, CLAuthorizationStatus status) { // If user has services disabled, we're just going to throw an exception for consistency. @@ -83,9 +90,12 @@ public override void Failed(CLLocationManager manager, NSError error) } } - #if __IOS__ - public override bool ShouldDisplayHeadingCalibration(CLLocationManager manager) => false; + public override bool ShouldDisplayHeadingCalibration(CLLocationManager locationManager) + { + locationManager.DismissHeadingCalibrationDisplay(); + return false; + } #endif #if __TVOS__ @@ -169,4 +179,4 @@ private void StopListening() manager.StopUpdatingLocation(); } } -} \ No newline at end of file +}