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

on iOS 14 the "Allow Location" prompt is show very briefly, then it instantly goes away before I'm able to click "Use location while in App" #1489

Closed
aherrick opened this issue Nov 2, 2020 · 10 comments
Labels
need-more-information Need more information to investigate a bug or proposal

Comments

@aherrick
Copy link

aherrick commented Nov 2, 2020

What I'm seeing is when requesting location, on iOS 14 the "Allow Location" prompt is show very briefly, then it instantly goes away before I'm able to click "Use location while in App"

Is this issue related? Below is my simple code. Wasn't sure if its somehow related to this:

https://stackoverflow.com/questions/7888896/current-location-permission-dialog-disappears-too-quickly
#1066

     while (true)
                {
                    if (await Permissions.CheckStatusAsync<Permissions.LocationWhenInUse>() == PermissionStatus.Granted)
                       break;

                    await AppHelper.RequestAsync_Fixed<Permissions.LocationWhenInUse>();
                }

                var request = new GeolocationRequest(GeolocationAccuracy.Medium)
                {
                    Timeout = TimeSpan.FromSeconds(30)
                };

                var location = await Geolocation.GetLocationAsync(request);

Video showing the issue:

https://streamable.com/3o51ah

Originally posted by @aherrick in #1390 (comment)

@mattleibow
Copy link
Contributor

This will probably be fixed once we merge #1487

Then you won't need to use this code as either.

@aherrick
Copy link
Author

aherrick commented Nov 5, 2020

@mattleibow awesome thanks for the response! once the new version is pushed i'll update and try it out. if its successful i'll close this puppy out. 👍

@mattleibow
Copy link
Contributor

You can test the fix in the nuget from the artifacts here:
https://dev.azure.com/xamarin/public/_build/results?buildId=30010&view=results

I'm going to just make sure that VS2017 is not broken with this, and then I'll merge and then the build will go out to the preview feed: https://aka.ms/xamarin-essentials-ci/index.json

@aherrick
Copy link
Author

aherrick commented Nov 7, 2020

@mattleibow hi! is this part of the beta 3 release that just dropped? if so i'm not seeing the issue fixed :(

@aherrick
Copy link
Author

aherrick commented Nov 7, 2020

when i keep this code in

  while (true)
                {
                    if (await Permissions.CheckStatusAsync<Permissions.LocationWhenInUse>() == PermissionStatus.Granted)
                       break;

                    await AppHelper.RequestAsync_Fixed<Permissions.LocationWhenInUse>();
                }

It actually flashes like the prompt is going to go away once, then it actually remains. so technically this could be used as as work around i think, but it still seems fishy. any thoughts? thank you!

@mattleibow
Copy link
Contributor

I believe it was fixed. Are you able to submit a small repro case?

I tested on my device and it stays available until I tap it. And now it also no longer hangs on iOS 14.

@aherrick
Copy link
Author

aherrick commented Nov 9, 2020

I'll look to submit a small repo case and see if I see it there. thanks!

@mattleibow
Copy link
Contributor

@aherrick Did you manage to get a repro case? I just tested on iOS 10 and iOS 14, the pop up stays around until I tap something.

@mattleibow mattleibow added the need-more-information Need more information to investigate a bug or proposal label Dec 3, 2020
@aherrick
Copy link
Author

aherrick commented Dec 6, 2020

@mattleibow thanks for checking back! Actually I was able to get this resolved things are looking good on the latest build! I'm closing this for now. cheers.

@aherrick aherrick closed this as completed Dec 6, 2020
@SiNeumann
Copy link
Contributor

@mattleibow I may have a repro case for this issue. It works without any problems after installation & first start. However if the user decides to change it in the (IOS)AppSettings to "Ask next time" this issue appears.
await Permissions.RequestAsync<Permissions.LocationAlways>(); returns instantanious with permission granted and the PopUp disappears. While the permission status hasn't changed.

SiNeumann added a commit to SiNeumann/Essentials that referenced this issue May 25, 2021
On IOS if you like to request LocationAlways you have to request locationWhenInUse first. This means in an average implementation one would have to consecutive call
await Permissions.RequestAsync<Permissions.LocationWhenInUse>();  
Permissions.RequestAsync<Permissions.LocationAlways>();  
Both use the static LocationManager instance.
Since RequestAsync<Permissions.LocationWhenInUse>() sets the result of the task completition source before cleaning up its locationManager there is a race condition where RequestAsync<Permission.LocationAlways>() already runs and thus this cleanup disposes the locationManager used by the second call. This will not always be the case but in my test around 50% of the time. Workaround wait 3-10 seconds in between the calls
jfversluis pushed a commit to SiNeumann/Essentials that referenced this issue Apr 4, 2022
On IOS if you like to request LocationAlways you have to request locationWhenInUse first. This means in an average implementation one would have to consecutive call
await Permissions.RequestAsync<Permissions.LocationWhenInUse>();  
Permissions.RequestAsync<Permissions.LocationAlways>();  
Both use the static LocationManager instance.
Since RequestAsync<Permissions.LocationWhenInUse>() sets the result of the task completition source before cleaning up its locationManager there is a race condition where RequestAsync<Permission.LocationAlways>() already runs and thus this cleanup disposes the locationManager used by the second call. This will not always be the case but in my test around 50% of the time. Workaround wait 3-10 seconds in between the calls
jfversluis added a commit that referenced this issue Apr 4, 2022
set result after cleanup of locationmanager #1489
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
need-more-information Need more information to investigate a bug or proposal
Projects
None yet
Development

No branches or pull requests

3 participants