16
Views
4
Comments
[Background Geolocation LT] stopOnTerminate: false
Question
Forge component by Tye Peck
2
Published on 22 Apr 2020

Hi there,

we tried the plugin with stopOnTerminate: false TemplateJSAction, like this:

if we close the app, no location events are generated. in the background it is works ok.

from the github demo video (https://www.youtube.com/watch?time_continue=219&v=aR6r8qV1TI8&feature=emb_logo) it tells me the location events should be coming even after closing the app with this setting. is there any way to make this work within the outsystems plugin?

thanks,

wilko

Rank: #1632

Hi Wilko, 

Happy to help with this. 


Firstly, did you manage to have a look at the sample app provided?

We added a sample recently so hopefully that guides you on how to use the plugin. 


Basically, you need to call the StartWatchingBackgroundGeolocation when you want the app to start capturing location data, then use the provided weblock to retrieve the data as it it registered


Rank: #1708

Tye hi,

we switched to your plugin a couple of weeks ago and already have build things with it. because of some requirements we need to comply with for the geolocation, we want the have the location tracker as robust as possible, and we see that if a user accidentally closes the app or restarts the device, the location tracker stops.

this morning i downloaded the plugin and sample app again, and tweaked it a little:

so every time there is a location event, we store it in a local table on the device. that works fine if the app is in the foreground or the app is running and another app is in the foreground. 

what we saw is that the maker of the github repo claims that even when you close the app or restart the device, the location tracking should continue. So we added the "stopOnTerminate: false," to the StartWatchingBackgroundGeolocation TemplateJSAction like this:

but that doesn't work. if i close the app, the background location services stop. but in the from the github demo video (https://www.youtube.com/watch?time_continue=219&v=aR6r8qV1TI8&feature=emb_logo) around 3:30, it tells that the githup repo is capable of running the location services even after the app has closed. so we want that to work. how can we do that?

thanks ahead,

wilko

Rank: #1632

Hi  Wilko, 

Thanks so much for the explanation. 

We now understand exactly what it is you are trying to achieve.

Also, good to hear you are getting some good use cases out of the plugin. 


From my research on the documentation page https://transistorsoft.github.io/cordova-background-geolocation-lt/interfaces/_cordova_background_geolocation_lt_.config.html#stoponterminate

It appears that the plugin handles thing differently when the stop on terminate is false and the app is in the background. 


From my research, it appears the best way to handle this is to use the URL parameter provided by the plugin (we do not expose this parameter so please feel free to add it in manually for now)

This will allow the application to send the location events to the server via the URL specified (details in the above documentation) for you to process however way you wish. 

Obviously you would need to set up a rest API in OutsSystems to manage this and have your application pull the latest location data from the API when it reopens as this is not stored on the device itself. 


I hope this makes sense. 

Happy to attempt to set up a sample project to demonstrate this functionality if needed?

Please do let us know. 


Regards,  

Rank: #1708

tye hi,

we will try to make an implementation based on your recommendations. the rest api and so on we can manage. the url is needed for android as the ios app will reboot?

we have a requirement that location history should be on the local device unless pulled by some specific condition.if we use the url, then all location history will always go to the server instead of the local device, for foreground, background as well as on terminate? if so, we need need to rethink the geolocation process we have.

for the url we will make it a parameter and put a switch on the url for the environment specific url

i'll let you know hoe we progress.

thanks,

wilko