Closed Csaba8472 closed 3 years ago
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.
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
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 :)
@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?
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.
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 ;-)
@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:
ListenerSettings
an option of which type of permission to require, defaulting to WhenInUse.
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)