-
Notifications
You must be signed in to change notification settings - Fork 59
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
Editable timeout and new parameter #34
Comments
This has been requested before, but I am reticent to include a configuration option for Android when an equivalent option does not exist for iOS. Is the distance filter option not sufficient for your needs? |
OK I didn't know that. But I need timeout, because I need request position periodically. For example every 30 seconds. I understand different options for different OS should be complicated. But in Cordova / Capacitor plugins it is normal. For my pour. iOS is not important for my purposes. I work on Android app only. |
I am sympathetic to your cause. Could you please explain to me your use case, and why a distance filter is not sufficient? |
Distance filter is not sufficient, because I need get location in long interval in some situation, for example every 30 seconds, but device is on one place. Yes I can make some workaround in app controler, but I think, get position from OS api is better, when API has this feature. |
Yes, but why do you need the location every 30 seconds if the devices has not moved? Is it just to trigger something in the UI? |
Exactly as you said. App runs on the foreground / background and every X seconds send location to server. |
Why does the server require location updates every X seconds, even if the location has not changed? |
It doesn't matter at all. I have such a request from a customer. He needs to be 100% sure that the device is in place or in motion at such a time and at such an interval. When the object moves 10 km per hour, it travels a different distance than it travels 100 km per hour. |
I see. The requests to the server are keeping the connection alive, so to speak. |
Would you be happy if the setting was defined in |
I'm afraid not :-(. The requirement is to change the timeout from FE. So it can be up to 15 seconds or 60 seconds depending on the user. |
There are three methods on
Are you looking to control every one of these? There is also the option of pulling the Android source code into your own project. It is just two classes and a few imports. Then you can have as much control as you need. |
I would like a feature like this for this reason: On my application i set distance filter to 5 meter and normally i receive a location with a speed value. I also use this speed value to do things(example: more speed value = more volume, but it can be 'distribute more salt on the road' so if speed is 0, i must distribute 0 salt and the vehicle run at 10km/h i must distribute 1kg salt, at 20km/h 2kg salt ...) But what happens if in less then 5 meter the vehicle stops to run? I doesn't receive any update and i continue to think that my car is in motion and i continue to distribute salt. A mount of salt :) At this point i must control myself that the last update is old and reset my speed. |
@gine How do you handle the situation that:
In both scenarios, location messages will not be received. Do you stop distributing salt when no messages appear for a given period? |
@diachedelic the salt distributor has a "stupid" PLC the try to connect to me(i am a server, yes it's strange.. can't explane now) every 100ms for N times and i must respond with phone status. If no response arrive, the plc change from manual mode to auto mode. At the moment i'm testing it with gps meter = 5 and it's impossible to get speed = 0.. i'm testisting realy now. sure, i can put a timer in the app that each N ms look if i have a new gps data but it's better what we are asking and that you implement a new type of filter. I will try with gps meter filter to 1m and i'll wtite what happen.. A lot of data drain a lot of cpu :( |
With 1mt filter work really better because the car breaking need at least 1 mt to stop the car but sometimes still happen |
Hello, This plugin works perfectly fine on both iOS and Android. However it drains battery very fast. My app requires user to have it's location tracked all the time (well almost all the time ... it's a delivery app). I tried using stale position true and distance filter of 50m, but it had no impact on the battery usage. My suggestion is to have the option to have the location checked every lets say 30 sec, then the service will go 'dormant' and not check for device location for the next 30 seconds. Might be stupid but I can't think of any other way I can save the battery usage. Thank-you! EDITI think on Android this could be achieved if if you change this line to accept an input, not a hard-codded value of '1000'. |
That's a shame the distance filter does not help with battery drain. Was this the case on both iOS and Android? I think I have to accept that this plugin needs a setting which controls Android's On Android, it is also possible to use the PRIORITY_BALANCED_POWER_ACCURACY priority for coarser location updates, about 100m. I would be interested to know how using this priority instead affects battery usage on your device. Could you please see if that gives an improvement? It should be possible to just modify the file and rebuild. |
Any news on this matter? |
@josuelmm What is your use case? |
Being able to change the values of: From Ionic |
Hello Sir , i am not sure if you still need fix , i did the exact same thing as i needed the same thing as you xD so , what you need to do is simple in and set config distanceFilter: 0 you will receive the location every 30 seconds even if you don't move :) , i made pull request with editable interval from capacitor |
Can you make a PR? |
hi! is this fix applicable on android only? |
yes, its only for android |
i see, noob question : how can i install zack's forked repo? i tried using npm install but got failed |
Did you try |
still got the error dear sir, here's the error |
Did you first remove the @capacity-community/background-geolocation package from your package.json? It can not coexist with Zack's fork. |
yes, i'm well aware of it, here's the proof |
If you stumble across this issue also, consider to change the relevant lines in your local folder node_modules/..../BackgroundGelolocationService.java before building again according to the new android API: LocationRequest.Builder locationRequestBuilder = new LocationRequest.Builder(30000); This seems to result in a reasonable background action (I have not tested the battery drain over time). |
Hi, I just stumbled across this plugin which works really well. For my use case, I want to periodically check the location of some users while they approach a certain destination and sync it (if the location changed) with the backend for some dispatcher to be informed. I want this to be as energy efficient as possible, as I often only have to request the location every few minutes. So far I read that the iOS part is making difficulties regarding the timeout parameter. I have little knowledge of iOS and swift, but just tried out if a native timer can be used. if let interval = call.getInt("interval") {
manager.startUpdatingLocation()
Timer.scheduledTimer(withTimeInterval: TimeInterval(interval), repeats: true) { _ in
manager.requestLocation()
}
} However, inside As I stated, I don't have much knowledge about swift, but would like to understand what the biggest concern is? |
I'm surprised that works in the background. What interval values did you try? Did the status bar turn blue whilst the app was in the background? If this approach works in the background, turns out to be energy efficient, and gives accurate results, I will add an "interval" option. However, |
Hi, sorry for the late reply. I didn't have access to a Mac for building iOS, during the last days. I tried 10 seconds, 30 seconds, 1 minute, 5 minutes and 15 minutes. However, the status bar turned blue in the beginning, but afterwards it only turned blue again when the GPS tracking was done (every |
After adding this
I tried above solution and got this error Any idea how to solve this |
Hi, I forgot this line at the end (again, according to the new android api): LocationRequest locationRequest = locationRequestBuilder.build(); |
Problem
There is no option to set custom timeout and setFastestInterval parameter.
Solution
The text was updated successfully, but these errors were encountered: