Flutterlocation: Background location tracking, when app closed

Created on 18 Mar 2020  路  22Comments  路  Source: Lyokone/flutterlocation

Thanks for the awesome library

Please, add background location tracking
So app closed but location tracking continue

This approach do not really works:
https://github.com/Lyokone/flutterlocation/wiki/Background-Location-Updates
more over it require static handler function that is not practical

inactive new_feature

Most helpful comment

Best alternative I found so far is the following:

  • on iOS, use background_locator plugin
  • on Android use foreground_service together with geolocator plugin

Could not get flutterlocation to work with foreground_service but geolocator does a fine job.

You can just stream data from the background_locator isolate to your app or from the foreground_service to your app and it'll stay alive.

All 22 comments

Hey ! I'm waiting for an official plugin to demonstrate how to properly use Service Aware which is the official implementation for Android plugin ... Might experiment a bit there if nothing is published. It is planned tho :)

Hello @Lyokone,
Thanks for the plugin, it's super useful.

I need to create a gps-based app, much like a navigation system (think Google Maps / Waze / iOS Maps). Would the approach in https://github.com/Lyokone/flutterlocation/wiki/Background-Location-Updates be suitable for this?

@z-dmitri says "it doesn't really work", what are the drawbacks ?

Or what could be an alternative using flutter? I'm new to smartphone dev and I find it pretty hard to find good resources on this topic.

On my iPhone, when using Waze or Google Maps for navigation, a blue banner shows at the top of my screen, saying that Waze is using my location despite the app not being in foreground. I want to achieve the same.

On this page they say that iOS apps are considered in use when running in the background with the background location usage indicator enabled.

And a comment on this SO question says: if your app has "when in use location permission", and you set background updates on your location manager and call startUpdatingLocation the blue indication is shown.

Any idea how I can do this using flutter? This feels like a feature that could be added to this plugin.

Any updates on this issue?

Best alternative I found so far is the following:

  • on iOS, use background_locator plugin
  • on Android use foreground_service together with geolocator plugin

Could not get flutterlocation to work with foreground_service but geolocator does a fine job.

You can just stream data from the background_locator isolate to your app or from the foreground_service to your app and it'll stay alive.

I don't know if you have seen this but both the article and code of this one looks interesting:

https://medium.com/flutter/executing-dart-in-the-background-with-flutter-plugins-and-geofencing-2b3e40a1a124

https://github.com/bkonyi/FlutterGeofencing

might be someone familiar with both iOS and Android can perfection this and add it to this plugin.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

push

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

up

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Im looking forward to this! thx

Im looking forward to this! thx

+1

Best alternative I found so far is the following:

  • on iOS, use background_locator plugin
  • on Android use foreground_service together with geolocator plugin

Could not get flutterlocation to work with foreground_service but geolocator does a fine job.

You can just stream data from the background_locator isolate to your app or from the foreground_service to your app and it'll stay alive.

@julien-h do you mind to upload a sample of this approach on github?

Best alternative I found so far is the following:

  • on iOS, use background_locator plugin
  • on Android use foreground_service together with geolocator plugin

Could not get flutterlocation to work with foreground_service but geolocator does a fine job.

You can just stream data from the background_locator isolate to your app or from the foreground_service to your app and it'll stay alive.

Hi @julien-h , Can you please share a sample code?

Regards,
Shyam

any updates on this feature? Would be sick to be able to get location updates in the background!

+1 also in need to be able to track gps location on both Android and iOS whilst the app is suspended in the background and/or the device screen is off/locked.

Best alternative I found so far is the following:

  • on iOS, use background_locator plugin
  • on Android use foreground_service together with geolocator plugin

Could not get flutterlocation to work with foreground_service but geolocator does a fine job.

You can just stream data from the background_locator isolate to your app or from the foreground_service to your app and it'll stay alive.

https://pub.dev/packages/background_locator documentation suggests that both iOS and Android are supported!?

Also - there is a new library https://pub.dev/packages/background_location

Hopefully the support for background tracking that appears to be in the above two libs are added to this one!

You can check how I implemented the background collection in this app: https://github.com/julien-h/tmd-data-collection-app/tree/master/smartphone-app/lib

It worked fine 3 months ago. No longer working on it now so not answering questions.

@julien-h We are seeing success with just using the background_locator in both iOS and Android devices and emulators to track geolocation in foreground and background usage of the app. Curious if you still require using numerous separate packages for the two devices?

@julien-h We are seeing success with just using the background_locator in both iOS and Android devices and emulators to track geolocation in foreground and background usage of the app. Curious if you still require using numerous separate packages for the two devices?

Thanks - I need to test background_locator on a few different devices, but initial tests are working. Out of interest, do you happen to know of a reliable package for converting long/lat into poly-lines to draw a path thats been provided?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Hi, sorry for not responding for a long time.
3.2.1 has some support for background location. It can be improved but it's a start :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Robouste picture Robouste  路  7Comments

giudon010 picture giudon010  路  3Comments

RomanJos picture RomanJos  路  4Comments

zeienko-vitalii picture zeienko-vitalii  路  7Comments

Gintasz picture Gintasz  路  9Comments