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

Remove CheckAlwaysPermissions call in iOS 13 and above #328

Closed
wants to merge 1 commit into from

Conversation

Csaba8472
Copy link

Fixes #289

Before iOS13 Always meant foreground + background but from iOS13 always means when the app is running(foreground+backgorund) + app is not running(e.g.: app uses geofences)

@evan-masseau
Copy link
Contributor

Hi, I experienced an issue with this permission check as well. I'm porting a location-tracking iOS app to Xamarin.Forms. In my experience, and from my reading of apple's docs, what you described has been the behavior of "Always" vs "When In Use" all along, not just iOS13.

https://developer.apple.com/documentation/corelocation/choosing_the_location_services_authorization_to_request

So I'd propose the fix here is to only require "Always" permission if you're using StartMonitoringSignificantLocationChanges. To use "StartUpdatingLocation" you should only need "When in Use" permission regardless of whether background is enabled. I raised an issue #329 for what I've described, here's a PR: #330

@Csaba8472
Copy link
Author

Csaba8472 commented Oct 4, 2020

hi @evan-masseau

didn't find older docs but based on this post it seems always and when in use works as I described.

StartMonitoringSignificantLocationChanges is a type of setting for the location update frequency, I think. If this is true, StartMonitoringSignificantLocationChanges should work both in always and when in use.

Btw we use the lib with this modification, so if something wrong with this approach, we have an issue to fix :)

@TheNewNewbie
Copy link

@Csaba8472 I also encountered the same Problem as you and your solution works for iOS 13. But I get a problem with iOS 14 when setting the Location permission "Manually" in the iOS Settings to "While Using the App" (when setting it via the Request-Permission-PopUp it works fine!). The problem is that the Plugin does not recognize that it has the "WhenInUse"-Permissions and tries to request permissions but the PopUp never appears (maybe because the system knows that the permission already are granted...). Everytime the Currently does not have Location permissions, requesting permissions -Message appears in the console.
Do you also have this issue?

@Csaba8472
Copy link
Author

sorry for the late answer, tested it and it works without the error message. The difference could be that we check and request permissions with Xamarin.Essentials.

@TheNewNewbie
Copy link

Yeah, that will be it. We eventually did a lokal Fork of the Project and replaced the usage of the Permission-Plugin with some Xamarin-Essentials Permission handling...But thanks for your answer anyway ;-)

@evan-masseau
Copy link
Contributor

@Csaba8472 I was misinterpreting the ListenForSignificantChanges service, I thought that had to do with region monitoring. I'm going to close my PR.

However I still think there's an unresolved issue with the permission check. Here is an explanation of When in Use vs Always from the apple (italics mine) https://developer.apple.com/documentation/corelocation/choosing_the_location_services_authorization_to_request

When In Use
Your app can use all location services and receive events while the app is in use. In general, iOS apps are considered in use when they're in the foreground or running in the background with the background location usage indicator enabled.
Always
Your app can use all location services and receive events even if the user is not aware that your app is running. If your app isn’t running, the system launches your app and delivers the event.

"When In Use" permission is sufficient to start StartUpdatingLocation with AllowBackgroundUpdates if your plist includes Location in UIBackgroundModes. The user will see the blue banner and status bar icon if they've only granted When In Use. The GeolocatorPlugin should not consider "Always" permission to be required for StartUpdatingLocation regardless of whether "AllowBackgroundUpdates" flag is true. And this is borne out in my testing of different OS's and past experience with my previous Swift application.

So I feel like this plugin should either:

  • Only ever check for WhenInUse permission. The developer can request Always permission in their own code.
  • OR add to ListenerSettings an option of which type of permission to require, defaulting to WhenInUse.

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

Successfully merging this pull request may close these issues.

Incorrect assumption on permission checking
4 participants