Hi SamoSimoni-6501,
Welcome to our Microsoft Q&A platform!
It's a known issue which has been reported on GitHub, you can triage it in the link: https://github.com/xamarin/Xamarin.Forms/projects/3#card-54694446
To handle this issue, here are some workarounds you can try.
If it's a single page, just set the MainPage in App.xaml.cs as follows.
MainPage = new MainPage(); // don't use "new NavigationPage()"
If it's not a single page and you need to use NavigationPage to push new pages. Try to use Xamarin.Essentials: Preferences to record if permission requested.
Here is a simple demo you can refer to.
bool showNewPage = false;
// button to get location(permission request pop up)
private async void Button_Clicked(object sender, EventArgs e)
{
Preferences.Set("permission_request_popup", true);
showNewPage = false;
Console.WriteLine("click");
try
{
var location = await Geolocation.GetLastKnownLocationAsync();
if (location != null)
{
Console.WriteLine($"Latitude: {location.Latitude}, Longitude: {location.Longitude}, Altitude: {location.Altitude}");
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
protected override void OnDisappearing()
{
bool key = Preferences.Get("permission_request_popup", false);
if (key == true && showNewPage == false)
return;
base.OnDisappearing();
Console.WriteLine("Disappearing");
}
// button to push new page
private async void Button_Clicked_1(object sender, EventArgs e)
{
showNewPage = true;
await Navigation.PushAsync(new Page1());
}
Regards,
Kyle
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.