Closed HugoHeneault closed 4 years ago
This is normal. These are the result of iOS 13 changes to location authorization. I blogged about it here last year.
These changes are described in detail in the Apple video What's new in Core Location
You'll be interested particularly at the time beginning at 3:40 and the phrase "Provisional Always Authorization".
Thanks for the blog post, got it! 👍
So there is no way to check if user manually gave the "Always" authorization? For my running app it means users will start tracking, put the phone in their pocket and have no idea that their localization isn't tracked anymore?
This is quite weird, we have no ability to check and coax the user to manually pick always?
So there is no way to check if user gave the "Always" authorization?
Correct. The User Perspective vs What Your App Sees:
Later, when the delayed "Promote to Always Allow" dialog is presented by the OS, after the plugin has detected the device is moving, and the user selects Change to Only While Using, you will receive an onProviderChange
event showing the user has selected WhenInUse
.
At that point, you can begin bugging them to select Always.
Right. But if the we started the plugin in foreground mode, it should continue in the background, right? On my tests it doesn't seem to work this way.
WhenInUse
will continue tracking in background ONLY IF you engage location-services while the app is in the foreground with BackgroundGeolocation.changePace(true)
.
The plugin cannot automatically turn on location-services and initiate tracking while the app is in the background with WhenInUse authorization. This has always been the case.
Example: A jogging app with WhenInUse
authorization where the user clicks a [Start Workout]
button.
In the /example
app in this repo, this is the green [ > ]
in the bottom toolbar.
Great! Thanks. I'm gonna check that later :)
Your blog post and the video you gave me should really be added on the https://pub.dev/documentation/flutter_background_geolocation/latest/flt_background_geolocation/ProviderChangeEvent-class.html page or somewhere we can understand how it works. 📚
Hello @christocracy
I should reopen this issue as we really don't get locations update when 1st launched app got "when app is active mode" authorization and screen got locked.
Here are some logs with this timeline:
09:30:28
09:30:32
09:30:44
09:31:57
when I unlock the device. Did I got something wrong?
Sounds like you're experiencing the new changes to iOS 13 Location Authorization. Have you read my blog entry about it from last year?
You can easily test the "first app launch" scenario in the iOS Simulator, simulating location with Freeway Drive.
@christocracy Yes I already read your post (see discussion above).
But it's not working as you said:
WhenInUse
will continue tracking in background ONLY IF you engage location-services while the app is in the foreground withBackgroundGeolocation.changePace(true)
.
How is Strava handling it? We don't need to lock/unlock the device on first app launch to get it working in background?
Thanks for your support. Appreciate it 👍
Hi Chris! 👋
A small issue about authorizations on iOS. Would you help us? Thanks!
Your Environment
flutter doctor
):[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3) [✓] Xcode - develop for iOS and macOS (Xcode 11.5) [✓] Android Studio (version 3.6) [✓] Android Studio (version 4.0) [✓] VS Code (version 1.45.1) [✓] Connected device (3 available)
• No issues found!
Expected Behavior
User should be prompted to authorize "always" the app to access position
Actual Behavior
There is no choice with "Always" option.
When we choose "When in app is active", the providerChanged event returns
AUTHORIZATION_STATUS_ALWAYS
instead ofAUTHORIZATION_STATUS_WHEN_IN_USE
.When I choose "When app is active" in settings I correctly get an onProviderChange event with
status
:AUTHORIZATION_STATUS_WHEN_IN_USE
Steps to Reproduce
(the strings in french mean: "Authorize when app is active", "authorize once" and "refuse")
Context
Check that user always have
AUTHORIZATION_STATUS_ALWAYS
before tracking their positionDebug logs
Logs
``` 14:54:09.418075+0200 Runner 🔵-[TSLocationManager onResume:] enabled? 0 14:54:22.824369+0200 Runner ℹ️-[TSLocationManager removeListener:callback:] location 14:54:22.824434+0200 Runner ℹ️-[TSLocationManager on:success:failure:] location 14:54:22.824496+0200 Runner ℹ️-[TSLocationManager removeListener:callback:] providerchange 14:54:22.824556+0200 Runner ℹ️-[TSLocationManager on:success:failure:] providerchange 14:54:22.824594+0200 Runner ⚠️-[TSLocationManager log:message:] #ready already called. Redirecting to #setConfig 14:54:22.844409+0200 Runner ℹ️-[TSLocationManager doStart:] trackingMode: 1 14:54:22.848331+0200 Runner 🔵-[TSLocationManager setPace:] 1 14:54:22.922359+0200 Runner 🎾-[TSLocationManager startUpdatingLocation] Location-services: ON 14:54:22.927413+0200 Runner 🎾-[TSLocationManager startMonitoringBackgroundFetch] BackgroundFetch: ON 14:54:26.703547+0200 Runner 🔵-[TSLocationManager changePace:] isMoving: 1 14:54:26.704101+0200 Runner 🔵-[TSLocationManager setPace:] 1 14:54:26.707195+0200 Runner 🎾-[TSLocationManager startUpdatingLocation] Location-services: ON 14:54:28.666101+0200 Runner 🔵-[TSLocationManager locationManager:didChangeAuthorizationStatus:] status 3 14:54:28.670825+0200 Runner ℹ️-[TSLocationManager locationManager:didUpdateLocations:] Received stale motionchange location. Retrying... 14:54:28.714988+0200 Runner ℹ️-[TSLocationManager locationManager:didUpdateLocations:] Received stale motionchange location. Retrying... 14:54:28.988804+0200 Runner ✅-[TSLocationManager locationManager:didUpdateLocations:] Acquired motionchange position: <+45.18019592,+5.71993240> +/- 65.00m (speed -1.00 mps / course -1.00) @ 09/06/2020 14:54:28 heure d’été d’Europe centrale 14:54:29.011172+0200 Runner 🎾-[TSLocationManager startUpdatingLocation] Location-services: ON 14:54:29.015875+0200 Runner 🔵-[TSLocationManager calculateMedianLocationAccuracy:] Median location accuracy: 65.0 14:54:29.016256+0200 Runner 🎾-[TSLocationManager startMonitoringSignificantLocationChanges] 14:54:29.041892+0200 Runner ✅-[TSLocationManager persistLocation:]_block_invoke INSERT: 0CBFDD07-52D8-4CE8-BFF7-08B8BFEFFF24 14:54:31.614537+0200 Runner 🔵-[TSLocationManager calculateMedianLocationAccuracy:] Median location accuracy: 65.0 14:54:31.614574+0200 Runner 🔵-[TSLocationManager calculateMedianLocationAccuracy:] Median location accuracy: 65.0 14:54:31.668122+0200 Runner ✅-[TSLocationManager persistLocation:]_block_invoke INSERT: 6E9639BD-D5B5-492D-8E85-35F60EE31F90 14:54:31.674787+0200 Runner ✅-[TSLocationManager persistLocation:]_block_invoke INSERT: D5EF293E-AC66-4BE4-9942-F6D466CD4C45 14:54:32.918848+0200 Runner 🔵-[TSLocationManager calculateMedianLocationAccuracy:] Median location accuracy: 65.0 14:54:32.935889+0200 Runner ✅-[TSLocationManager persistLocation:]_block_invoke INSERT: 55368D00-C2FC-482E-841C-1B6ECCEAAE51 14:54:33.713947+0200 Runner 🔵-[TSLocationManager calculateMedianLocationAccuracy:] Median location accuracy: 65.0 14:54:33.717756+0200 Runner ✅-[TSLocationManager persistLocation:]_block_invoke INSERT: E3A80E1F-2D78-40E1-BC92-710FE5AC98BD 14:54:46.052489+0200 Runner 🔵-[TSLocationManager calculateMedianLocationAccuracy:] Median location accuracy: 65.0 14:54:46.089349+0200 Runner ✅-[TSLocationManager persistLocation:]_block_invoke INSERT: 3DCDF492-5FA0-4D90-8781-D92BA6E43A06 14:54:48.534007+0200 Runner 🔵-[TSLocationManager onSuspend:] enabled? 1) ```Thanks for your help!