Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public override async Task<PermissionStatus> RequestAsync()
if (status == PermissionStatus.Granted || status == PermissionStatus.Disabled)
return status;

EnsureMainThread();
// No need to ensure main thread here as the permission request dialog will be shown on the main thread

#pragma warning disable CA1416 // https://github.com/xamarin/xamarin-macios/issues/14619
#pragma warning disable CA1422 // Validate platform compatibility
Expand Down Expand Up @@ -181,7 +181,11 @@ internal static Task<PermissionStatus> RequestLocationAsync(bool whenInUse, Acti
del.AuthorizationStatusChanged += LocationAuthCallback;
locationManager.Delegate = del;

invokeRequest(locationManager);
// Only use the main thread for the actual permission request dialog
MainThread.BeginInvokeOnMainThread(() =>
{
invokeRequest(locationManager);
});

return tcs.Task;

Expand Down
2 changes: 1 addition & 1 deletion src/Essentials/src/Permissions/Permissions.ios.watchos.cs
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ public override async Task<PermissionStatus> RequestAsync()
if (status == PermissionStatus.Granted)
return status;

EnsureMainThread();
// No need to ensure main thread here as the permission request dialog will be shown on the main thread

#pragma warning disable CA1416 // https://github.com/xamarin/xamarin-macios/issues/14619
return await LocationWhenInUse.RequestLocationAsync(false, lm => lm.RequestAlwaysAuthorization());
Expand Down