Skip to content
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

Pluggin still run in background aven if app is closed #1

Closed
Sly2024 opened this issue Dec 24, 2019 · 14 comments
Closed

Pluggin still run in background aven if app is closed #1

Sly2024 opened this issue Dec 24, 2019 · 14 comments

Comments

@Sly2024
Copy link

Sly2024 commented Dec 24, 2019

Hello,

I managed to make the package to work.
However, when I close the app on android (not just put in background), the location tracking is still active, draining the battery.
How to automatically stop the tracking in this case?

@mehdok
Copy link
Collaborator

mehdok commented Dec 24, 2019

That's the point of using this library, it will continue to run and get location updates in background no matter what. For stopping this you have to call BackgroundLocator.unRegisterLocationUpdate().

@Sly2024
Copy link
Author

Sly2024 commented Dec 24, 2019

I know and that's perfect.
I added the BackgroundLocator.unRegisterLocationUpdate() to the dispose function of my app but when I close the app, the location is still tracked.
I have to force kill the app to stop it.

@mehdok
Copy link
Collaborator

mehdok commented Dec 24, 2019

It might be a bug in the library, I Will check it. But Please be sure that dispose() function is getting called.

@Sly2024
Copy link
Author

Sly2024 commented Dec 24, 2019

Ok thanks
Otherwise, is it something to put in the application class?

@mehdok
Copy link
Collaborator

mehdok commented Jan 3, 2020

I ran the example app and the start stop buttons worked as expected without any problem, Please be sure that your dispose() method and BackgroundLocator.unRegisterLocationUpdate() is getting called.

@Sly2024
Copy link
Author

Sly2024 commented Jan 3, 2020

yes the buttons worked as expected
it is the dispose function that is not called, but according to my researches on google, this is a more general issue with flutter.
I'll continue searching and post a solution if i find one

@Sly2024 Sly2024 closed this as completed Jan 3, 2020
@Sly2024
Copy link
Author

Sly2024 commented Jan 3, 2020

Hello

I did some researches and here is what I understood:

  1. you create your flutter app, initialize the plugin and register it
  2. when the service has a new position that matches timing and distance, it is sent to the callback.
    However, if the flutter app is not running (for example if the user quit the app, not just background), the plugin recreate a new backgroundFlutterView to execute the associated code.
    Then, if the user launch the app, a new instance of flutter is launched
    Therefore, you have 2 flutter apps running.

What I would like instead, is that if there is no backgroundFlutterView, the background service should stop
Could you help me with that, because I don't know kotlin coding at all and I don't manage to understand how your code works

@Sly2024 Sly2024 reopened this Jan 3, 2020
@mehdok
Copy link
Collaborator

mehdok commented Jan 5, 2020

Fixed

@mehdok mehdok closed this as completed Jan 5, 2020
@Sly2024
Copy link
Author

Sly2024 commented Jan 7, 2020

For me, the behaviour is still not right.
Here is what I get with your example :

  1. I start the app and start the background location
    -> The log is working and displayed normally
  2. I exit the app (swipe up in the tray) without stopping the background location
    -> I still have the notification indicating that location is running in background
  3. I start the app
    -> the log is not displayed and does not update. The sticky notification is still active
  4. I start the background location
    -> Nothing happen even if the notification is still active
  5. I stop and restart the background location
    -> Nothing happen
    To get the app running normally again, I have to stop background location and then exit the app before l restart it

For me the correct behaviour should be either :

  • at step 2, the background location should stop in order to restart correctly at step 3
  • or at step 4, the app should receive normally the callback

@mehdok
Copy link
Collaborator

mehdok commented Jan 8, 2020

This is the expected behavior, The plugin won't stop locating automatically, you have to manually stop it.
As you stated in step 3, the example won't show log after coming back to ui, This is a bug in ui and I will fix it asap, but the plugin is working correctly in background. at this stage if you press stop the notification disappear too.

@Sly2024
Copy link
Author

Sly2024 commented Jan 8, 2020

Ok thanks for your answer

@bobppsureway
Copy link

It would be great if a "onTerminated" property added to the plugin. If true then unRegisterLocationUpdate() will be called when app is closed. Calling BackgroundLocator.unRegisterLocationUpdate(); in dispose() doesn't work.
And there should be some click actions on the sticky notification. Sth like stop tracking or resume the app.
This plugin is awesome!!
Looking forward the coming updates.

@mehdok
Copy link
Collaborator

mehdok commented Jan 11, 2020

@bobppsureway Please open a new issue for this.

@mehdok
Copy link
Collaborator

mehdok commented Mar 9, 2020

@Sly2024 @bobppsureway auto stop option added.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants