-
-
Notifications
You must be signed in to change notification settings - Fork 662
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
Add support for background location tracking #53
Comments
This is one of the main reasons I haven't switch one of my apps to Flutter, background location tracking is a must. Thanks for keeping this on track! |
I'm also looking into this. Wanting to build an app in a corporate setting with a background GPS tracking requirement. flutter/plugins#656 (mentioned above) isn't on Pub yet and only supports iOS. |
I ended up writing my own implementation (on Android, at least), based off this Google sample that runs when the app closes. I'm pushing the location data to firebase, so I didn't need to send anything back up the method channel. I just upload straight to Firebase using native code when a location result arrives. This means I can't generalise it to help this plugin out, but that sample repo might be useful. |
I found a solution to generalize your @aidandavis method. Update: The Google sample not prevent Doze Mode. If the device uses doze the network and the gps can be killed with your service too. Update 2: This stackoverflow thread help against chinese roms battery saving things, and adds app to protected list. |
That's definitely a way to do it. The problem still remaining is doing something with the data while the app is in background or the sytem chooses to close it. With regards to Doze, it should only apply when the phone is stationary (like on a table). There's no point tracking location updates at that point anyway - the last location sent prior to Doze would still be accurate. |
On top of this, Dart code could be embedded as the same way implemented in alarm_manager_android. The Android callback calls Dart code without the app running. |
I see that this feature was removed from the 2.1.0 milestone. Has it been pushed to the back burner? My project also would greatly benefit from this. |
Guys, any update on this? This feature can add wings to this plugin. It is must needed. |
It's maybe also worth noting that some devices can't get gps locations with the screen off. I've been stuck on this one for a while, and finally found it's down to the devices chipset. So it may be worth double checking that as well, especially if it's a low battery device like a watch. |
@ibrierley I am not sure about the wearables but all the devices (Mobile/Tablets) running API >= 16 are capable of getting location updates even when the screen is off. I tested that myself too. |
Yes, I've mainly been testing on a Huawei watch 2, and read a thread where there was a post with I think a Huawei engineer (may be wrong), saying it was set in the chipset, so they couldn't fix it (I'll post here if I can find the thread, but haven't seen it on a quick search). I've ended up turning the screen black, but I hate that solution :) (but it works, just not quite sure if it saves that much battery, so may end up forcing the screen on with something displaying). |
@martijn00 I wonder if Geofence plugin won't give a boost on this feature. I believe background execution would be a crucial one and many of us are expecting it. Let me know what do you think... |
Hope you guys can add BG service soon :) |
Hi! |
Hey guys what are your thoughts on https://pub.dartlang.org/packages/flutter_background_geolocation |
It does, but it costs $300+ |
@christocracy, I think your package is worth every cent however I'm just too poor atm :) Watching this space |
This comment has been minimized.
This comment has been minimized.
Looking forward to this! |
I tried to get the position periodically every 15 minutes and everything works well. |
@mvanbeusekom should I open a separate issue for supporting location updates while the app is in the foreground? |
Any updates on this? I just wanted to listen to updates while the app is not killed, like @mbilalakmal said. The location package already does this, but I prefer this package structure and API. |
Hi @temala I'm trying to do exactly what you have done! Could you please help me out with a reference or code snippet or anything to use background location with firebase ? |
Not perfect solution but if you want still use the Geolocator plugin in background mode (not terminated): The Works on iOS and Android. Example code:
|
@nanjadev Can you share the full code which package and versions? |
This is exactly what we have in code. |
@nanjadev thanks you... |
I have a bike app that get location every second. Up to version 7.03 we could get the location when the app was running in the backgound ( background as defined by mbilalakmal, see his comment 14 mar 2021). After upgrading we no longer could get the location when the app was in the backgound and we were forced to downgrade to version 7.03. |
Is it possible that one of the dependencies is causing the background permission problems? |
@ICP-Theo Do you have example of code of using a Foreground Service and Geolocator (7.0.3)? I've been trying to implement something to no avaiL... |
@cto-leaps In this version I did not pay any attention to Android but I had an older version written in C++ with a foreground service to get the location when the app ran in the background and that worked quite well. |
Exactly the same issue, did you find any fix ? |
Context: My fitness app is used for my user to track their position while they perform certain activities they launch themselves. I am not trying to detect or track them when they are not using the app. In the end, I used two separate approaches.
I use the latest version of GeoLocator and everything seems to work fine on both platforms. I'm still in test on Android and waiting for the app to be approved. But so far, so good. I hope this helps, @jesussmile ! |
@jesussmile I hope this helps someone |
I don't know if background location tracking means that the app should stay tracking the user location even if it's killed, in my case I need to track the location when the app goes to background, I had some issues with that like the
|
Could you let me know if you plan to support background location updates when the app is terminated? |
Also see: flutter/plugins#656
The text was updated successfully, but these errors were encountered: