Skip to content
This repository has been archived by the owner on May 15, 2024. It is now read-only.

Commit

Permalink
Need to cache locationmanager or dialog dissapears (#1072)
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesmontemagno authored Jan 31, 2020
1 parent c7b4a54 commit 72447a0
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,11 @@ internal static PermissionStatus GetLocationStatus(bool whenInUse)
};
}

static CLLocationManager locationManager;

internal static Task<PermissionStatus> RequestLocationAsync(bool whenInUse, Action<CLLocationManager> invokeRequest)
{
var locationManager = new CLLocationManager();
locationManager = new CLLocationManager();

var tcs = new TaskCompletionSource<PermissionStatus>(locationManager);

Expand Down Expand Up @@ -155,6 +157,8 @@ void LocationAuthCallback(object sender, CLAuthorizationChangedEventArgs e)
{
locationManager.AuthorizationChanged -= LocationAuthCallback;
tcs.TrySetResult(GetLocationStatus(whenInUse));
locationManager.Dispose();
locationManager = null;
}
});
return;
Expand All @@ -164,6 +168,8 @@ void LocationAuthCallback(object sender, CLAuthorizationChangedEventArgs e)
locationManager.AuthorizationChanged -= LocationAuthCallback;

tcs.TrySetResult(GetLocationStatus(whenInUse));
locationManager.Dispose();
locationManager = null;
}
}
}
Expand Down

0 comments on commit 72447a0

Please sign in to comment.