From 5b4cf5474da13e0f92dbc0a860cf6ebc0c55c282 Mon Sep 17 00:00:00 2001 From: James Montemagno Date: Thu, 30 May 2019 19:18:13 -0700 Subject: [PATCH] Add mroe null checks in LocationAuthCallback Should Fix #740 (#748) --- Xamarin.Essentials/Permissions/Permissions.ios.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Xamarin.Essentials/Permissions/Permissions.ios.cs b/Xamarin.Essentials/Permissions/Permissions.ios.cs index e4a9c48..d22d920 100644 --- a/Xamarin.Essentials/Permissions/Permissions.ios.cs +++ b/Xamarin.Essentials/Permissions/Permissions.ios.cs @@ -95,12 +95,14 @@ namespace Xamarin.Essentials void LocationAuthCallback(object sender, CLAuthorizationChangedEventArgs e) { - if (e.Status == CLAuthorizationStatus.NotDetermined) + if (e?.Status == null || e.Status == CLAuthorizationStatus.NotDetermined) return; - locationManager.AuthorizationChanged -= LocationAuthCallback; - tcs.TrySetResult(GetLocationStatus()); - locationManager.Dispose(); + if (locationManager != null) + locationManager.AuthorizationChanged -= LocationAuthCallback; + + tcs?.TrySetResult(GetLocationStatus()); + locationManager?.Dispose(); locationManager = null; } }