Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4.5.2-beta - issue #274 regression #280

Closed
nbsoftware opened this issue Oct 10, 2018 · 12 comments
Closed

4.5.2-beta - issue #274 regression #280

nbsoftware opened this issue Oct 10, 2018 · 12 comments

Comments

@nbsoftware
Copy link
Contributor

Hi,
4.5.1-beta fixed issue #274
I tested today 4.5.2-beta and the same issue seems to be happening again.
Would there be any reason for it?
I downgraded to 4.5.1-beta and it worked again as it should.

@nbsoftware
Copy link
Contributor Author

Hi James,

I know you are busy.
But I just saw that you recently updated your package.

Any chance to have a look at this one?
Thanks

@jamesmontemagno
Copy link
Owner

There was no changes in code at all, just the permissions plugin. Ensure you clean/rebuild it correct.

@nbsoftware
Copy link
Contributor Author

nbsoftware commented Nov 14, 2018

Hello James,

Believe me, I'm very aware of that tedious process of deleting bin & obj directories as well as issuing a rebuild all when upgrading / updating packages... I do that all the time, and it's a pain!

Having said that and doing it for every change, I tested all combinations of Plugin.Permissions & Xam.Plugin.Geolocator and there is definitely something wrong.

My tests concluded the following:

  • the latest 4.0.2-beta Plugin.Permissions does not work anywhere
  • the working combinations that work for now are different from iOS & Android.

More specifically, the only combinations that are working for me are:

  • iOS: Plugin.Permissions 4.0.1-beta & Xam.Plugin.Geolocator 4.5.3-beta
  • Android: Plugin.Permissions 4.0.1-beta & Xam.Plugin.Geolocator 4.5.2-beta

On Android:

  • using Plugin.Permissions 4.0.2-beta & Xam.Plugin.Geolocator 4.5.3-beta, requesting permissions generates an error message stating that the necessary permissions are not set in the manifest (but they are!!!)
  • using Plugin.Permissions 4.0.1-beta & Xam.Plugin.Geolocator 4.5.3-beta passes the permissions request but then GetPositionAsync gives a "Location refused" error

Unless I'm doing something wrong, there is definitely some issue.

On your side, have you tested your latest versions with your sample on each platform?

@jamesmontemagno
Copy link
Owner

Testing out my sample now!

@jamesmontemagno
Copy link
Owner

Upgraded sample works great. Checked into repo and attached here.
GeolocatorSample.zip

@nbsoftware
Copy link
Contributor Author

nbsoftware commented Nov 14, 2018

Hi James.

Call me stubborn... but no... your sample does exhibit the exact behaviour I'm seeing and which I was describing.

Follow this test scenario on iOS:

  • run your sample without any changes (uninstall it before so it does ask for permissions),
  • click on the second button "Get Current Location"
  • grant the "Always" permission
  • it works as it should i.e. location is retrieved instantly, no error messages
  • now go to settings, change the permissions to "When In use" (GetPositionAsync should still work right?!)
  • go back to the app and click again the same button... now it takes some significant time to answer (see the 8 seconds between the last two messages) and you should get the following log messages:
...
2018-11-14 23:32:22.856116+0100 GeolocatorSampleiOS[26201:819756] Currently does not have Location permissions, requesting permissions
2018-11-14 23:32:22.870684+0100 GeolocatorSampleiOS[26201:819756] AuthorizedWhenInUse
2018-11-14 23:32:30.872692+0100 GeolocatorSampleiOS[26201:819756] Location permission denied, can not get positions async.
...

In your sample's source code, the first

var hasPermission = await Utils.CheckPermissions(Permission.Location);

returns true! (which is expected) but the line:

var position = await locator.GetPositionAsync(TimeSpan.FromSeconds(Timeout.Value), null, IncludeHeading.IsToggled);

does take about 8 seconds and produces the 3 error messages above.

Now, change your solution and downgrade Plugins.Permissions to 4.0.1-beta in the GeolocatorSample project as well as in the GeolocatorSample.iOS project.
Clean all, rebuild all ;)
And run the same scenario, both work flawlessly.

Can you reproduce this behavior?

I'll test on Android tomorrow.

@jamesmontemagno
Copy link
Owner

This is different then what you said and is yes the expected result as to how iOS handles premissions. However, i am going to simplify this by removing the background junk from GetPositionAsync and then it will never check those :)

@jamesmontemagno
Copy link
Owner

jamesmontemagno commented Nov 14, 2018

The above would only happen if you have both permissions set and background items, it wouldn't happen if you just had WhenInUse only set.

@jamesmontemagno
Copy link
Owner

If you are only using GetLocationAsync i also recommend moving to Xamarin.Essentials.

@nbsoftware
Copy link
Contributor Author

nbsoftware commented Nov 15, 2018

This is different then what you said

Well, issue #274 tried to described exactly that.

The above would only happen if you have both permissions set and background items, it wouldn't happen if you just had WhenInUse only set.

If you mean by that that it only happens if we have set "Location Updates" in Info.plist and answering "While using" rather than "Always", well yes, that was the case.

And seeing the part of the code you removed, I can now see why it happened.
What I still don't get is why did this seem to be working when downgrading permissions to 4.0.1-beta... maybe just got lucky and it worked but it shouldn't really ;) Anyway, never mind this.

If you are only using GetLocationAsync i also recommend moving to Xamarin.Essentials.

I'm using Xamarin.Essentials already for other functionalities (great library indeed, so thanks!) so yes, at least for GetLocationAsync I might consider it.

@nbsoftware
Copy link
Contributor Author

Just tested out with latest 4.5.4-beta (and with Permissions 4.0.2-beta) and all seems to work as expected on both platform.

Stubbornness pays... eventually ;)

Thanks!

@jamesmontemagno
Copy link
Owner

YAY! I think for the great good! I now see how exactly it was happening

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants