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
Enable heartbeat to be sent automatically with async and Http Requests #1245
Comments
Why?? You're fighting an uphill battle. The OS doesn't want you to do this. This sort of behaviour is the reason that https://dontkillmyapp.com exists. If the plug-in says the device is stationary, it's pointless to keep reporting "here I am", "here I am", "here I am", wasting the device battery. |
You're responsible for requesting your own location in your onHeartbeat by calling .getCurrentPosition. The plug-in does NOT turn on location-services at all while stationary. The location provided to onHeartbeat is the "last known location". You'll never get what you want on iOS and Android is becoming more strict with "exact" timers. |
Thanks for answering, that totally makes sense, but our business is related to moving other companies' packages. One of our providers is now requiring us to report the location in a time window less than 5 minutes per point in the hole of travel. We are struggling to make that happen. Do you think that trying to do this will make the OS to kill the service? Even if we are not accessing the GPS but just the latest known position and sending it back? |
The easiest thing to do, is simply call .changePace(true) with a really large stopTimeout, forcing location-services to stay on, preventing the plug-in from entering the stationary state. With location-services ON, your app continues to spin the CPU and your code is completely alive to run your own Dart timers to call .getCurrentPosition. Be sure to call .changePace(false) when a "delivery" is complete or you'll kill the battery. |
Thanks! I will try that! |
This issue is stale because it has been open for 30 days with no activity. |
We need to keep calling our server with the latest know location every x seconds, even if the device is stationary, and we are using config async to call a service for that.
What we need to know how to do is that when the motion stops, the HTTP server stops being called and the heartbeat starts sending signals to the headless service or the listener. But they are not been sent to the HTTP server, it just beats.
It does make sense to me that this is the default behavior since it is beat, right? But for our use case, we still have to call the service when the beat is called, and so, how can we set up the library to still call the HTTP service even for heartbeat locations?
Your Environment
flutter doctor
): flutter 3.16.4 and dart 3.2.3Expected Behavior
The HTTP service is executed for the URL in the setup for the new locations and for all heartbeat events
Actual Behavior
The HTTP service is executed for the URL in the setup only for the new locations.
The heartbeat listeners and headless function are executed, but not the automatic HTTP service that is set up via the config.
Steps to Reproduce
Logs with the latest HTTP service call and motion change false
And then theres only heartbeat but no HTTP requests:
Logs only with heartbeat
Context
My company needs to have the location of the hole travel with times less than 5 minutes between each call, and even if the car is stopped, so we are trying to fetch them every 10 seconds or 30 to try to make it into that time window.
The text was updated successfully, but these errors were encountered: