loup-v / geolocation

Flutter geolocation plugin for Android and iOS.
Apache License 2.0
226 stars 94 forks source link

Background service not working with Android O #19

Open squashmode opened 6 years ago

squashmode commented 6 years ago

Android O has changed the way things work in the background, and this service will not work on an Android O device in the background.

To reproduce, run the example project on a virtual Android O device, while subscribed to location updates, turn off the screen of the device. Updates stop (actually slow down to about once every 30 minutes) until the screen is turned back on.

lukaspili commented 6 years ago

Background execution with location updates that wake up the application is not supported yet.

synio-wesley commented 6 years ago

I see the same thing. On Android N locations keep coming through when the app is backgrounded, but this does not happen on Android O.

Ideally, I would like this change on Android N:

And for Android O the same, but right now it doesn't even send locations when the app is in background.

Does the background tracking work well on iOS 11? I haven't been able to test this yet.

Do you know when this functionality could become available in this plugin? I'm working on an app that needs to track boats in open water and am now looking at Flutter instead of Ionic, partly because the geolocation plugins for Ionic are not working very well in background on iOS.

In any case, thanks for your work on this plugin. Hopefully we can go the Flutter way.

tegarkurniawan commented 5 years ago

Is it still not possible on Android oreo?

premy commented 5 years ago

@synio-wesley Could you explain how you get the backgorund updates to work in Android N or lower, with the screen off? During my tests the updates get buffered when the app goes in the background but .listen() is not called, therefore the coords are not being sent to firestore, as per my requirement. Tried it on several devices with background and unrestricted data access enabled for my app.

StreamSubscription < LocationResult > subscription = Geolocation.locationUpdates( accuracy: LocationAccuracy.best, displacementFilter: 10.0, inBackground: true, ) .listen((result) { if (result.isSuccessful) { saveResult(result); } else {} }); As soon as I turn on the screen again, saveResult() get's called by each of the buffered results.

Sly2024 commented 4 years ago

Hello, Does anyone know if the new version has the same behaviour ? Or is the .listen() called every time when the app is in background ?

suha-glal commented 4 years ago

I have tried it on Android version 9 and the location updates stop when the app is not active in the foreground. I have switched from the plugin I am using to this plugin just for this feature. Unfortunately, it is not working.

angel1st commented 4 years ago

@lukaspili - does the plugin support background execution already?

azeemgujjar commented 4 years ago

I have tried it on Android version 9 and the location updates stop when the app is not active in the foreground. I have switched from the plugin I am using to this plugin just for this feature. Unfortunately, it is not working.

which plugin you are using now for foreground let me know if you found some stable plugin, i am really sick of these basic issues.. even flutter editor's favorite widget also have issues.. and the extremely bad thing is plugins owners damn care about bugs/issues.. i can i noticed 70% of issues are still not replied by anyone.