Skip to content
This repository was archived by the owner on May 15, 2024. It is now read-only.
Merged
Changes from all 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 @@ -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();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if we come back in here without waiting for the flow to complete? We might leak...

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