flutter-geolocator
flutter-geolocator copied to clipboard
iOS background task terminating after period of time
🐛 Bug Report
When i have enabled foregroundNotificationConfig and i am using app for longer time lets say one day (app is running but in minimized state), location tracking wont work. I managed to find log when app is running longer than 30 seconds:
[BackgroundTask] Background Task 54 ("Flutter debug task"), was created over 30 seconds ago. In applications running in the background, this creates a risk of termination. Remember to call UIApplication.endBackgroundTask(_:) for your task in a timely manner to avoid this.
So probably it will terminate because of this. Is it possible to somehow make that background task longer?
Expected behavior
Tracking user if he minimize app / put phone to sleep for whole day (for example).
Reproduction steps
None
Configuration
Same as example
Version: 8.2.0
Platform:
- [x] :iphone: iOS
this is happening in the android devices too.
@mvanbeusekom Any ideas?
anyone tried to debug this? @mvanbeusekom
Did anyone of the participants in this thread found a solution or workaround to this problem?
This might be related to #1122
My guess is that Android eventually kills the activity hosting the Flutter engine. Using the foreground config just elevates the priority of the MainActivity making it less likely that Android will kill the application but it does not prevent it entirely. Foreground config is there mostly to help with short lived tasks where users may be switching between applications etc and you still want to keep the location tracking active. For much longer periods a library like flutter_foreground_task should be used where an entirely new Flutter engine is created in an Android foreground service that can live without the main activity and engine. It does make it a bit more complicated to work with. @mvanbeusekom maybe we should just update the description of the foreground config on the Android settings to state this?
So this issue is related with the flutter-debug job? I am developing background mode related app and got this message.
[BackgroundTask] Background Task 3 ("Flutter debug task"), was created over 30 seconds ago.
In applications running in the background, this creates a risk of termination.
Remember to call UIApplication.endBackgroundTask(_:) for your task in a timely manner to avoid this.
At a glance, I thought that I implemented native side in a wrong way.
Dear @bujdy,
Can you share some of your minimal reproducible code or an example project? Furthermore, it is unclear to me if this happens after approx 30 seconds or one day. Did you also implemented all the steps from the README regarding background location. And, @prabuddaFernando, have you added:
Kind regards,
Without additional information, we are unfortunately not able to resolve this issue. Therefore, we reluctantly closed this issue for now. If you run into this issue later, feel free to file a new issue with a reference to this issue. Add a description of detailed steps to reproduce, expected and current behaviour, logs and the output of 'flutter doctor -v'. Thanks for your contribution.
Any updates of it? i am getting this error
Runner[3633:1051724] [BackgroundTask] Background Task 144 ("Flutter debug task"), was created over 30 seconds ago. In applications running in the background, this creates a risk of termination. Remember to call UIApplication.endBackgroundTask(_:) for your task in a timely manner to avoid this.
i created a background fetch and i tried to simulate it using xcode but i got this error. Any idea?