Skip to content

Commit

Permalink
Add mroe null checks in LocationAuthCallback Should Fix xamarin#740 (x…
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesmontemagno authored and Schilli, Niklas committed Aug 28, 2019
1 parent 7cd61c4 commit c7fa246
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions Xamarin.Essentials/Permissions/Permissions.ios.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,14 @@ static Task<PermissionStatus> RequestLocationAsync()

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;
}
}
Expand Down

0 comments on commit c7fa246

Please sign in to comment.