Hi, I'm trying to find any plugin that can help me getting background location. I tried to use:

  1. Background Location Plugin Demo 
    • But I don't know how to generate an app to android, because the application doesn't appear on my Development tab in my Service Studio
  2. Mobile Background Location Plugin 
    • But I don't know what API I use in the GetLocationApiUrl Server Action
  3. Background Geolocation LT
    • But needs to pay to use at all was the one that works well, and was the easiest to configure.

Can anyone help me with any background location plugin? I need some help!


Bst Regards

I would combine the regular Location plugin (https://www.outsystems.com/forge/component-overview/1395/location-plugin) and a javascript timer library like Timing Events (https://www.outsystems.com/forge/component-overview/8422/timing-events). 

To use these you create a Block that uses the Interval method of the Timing Events. This method will then call a Client Action that will then request the current location. The results of this request will be the input of an Event of this block. Then you can place this block in the Layout of your choice and use it however you want. 

You can read on how to create a native Android app in the following document (https://success.outsystems.com/Documentation/11/Delivering_Mobile_Apps/Generate_and_Distribute_Your_Mobile_App/Generate_and_Distribute_Your_Mobile_App_for_Development_Tests#For_Android) but it should also work as a PWA (my personal recommendation)

Hi, Vincent Koning!! 

I will follow your recommendation, I created the block and put the timing events on it, but I don't understand this part "The results of this request will be the input of an Event of this block". Could you help me with this??

And another question, will this work when the app isn't open?


Bst Regards

Solution

Hi Bruno,

The event is meant for telling the consuming component that an update of location is available. It could look like this;

As for why you want to do this. It has to with Single-responsibility principle. You want to create a piece of logic that only does one (1) thing and it should be good at that thing but that is all it does. In this case it supplies the current location every several seconds. It doesn't take action upon the new location at all. So it doesn't display it, it doesn't plot something on the map and it surely doesn't store it in the database. 

What to do with the new location is for the consuming component to decide. This component can handle the new location how you see fit but again, try to let it do only one (1) thing. Either plot it on th map or store it in the database but certainly not both. If you want to do both the you will create 2 actions that do those 2 things separately (plot and store) and then combine it in a new action which sole purpose is to orchestrate those two (2) actions. So this actions sole purpose is orchestration, again following the SRP!

I created a demo to show you how you could implement this.

Greetings,

Vincent

Solution

I forgot to answer your other follow-up question. You can't keep requesting the location when the app isn't in the foreground natively but there are some forge component that let you do this. Please read the description with care and know that tracking devices without consent could be illegal or at least will be frowned upon by the user.

Greetings,

Vincent

Hi again!

Vincent Koning, too much thanks, you helped me so mutch with the DEMO. I have some error occuring, can you help me with this? 

I made the same you did in the DEMO.

Talking about the BackgroundMode Plugin, I will resolve this problem and try to use it! 


Bst Regards

Hi Bruno,

I'm glad that I have been able to assist you. Can you please check one of my reply as answer so other can find a solution to their similar issue quicker?

As for you timeout question; This seems like a separate issue as it has nothing to do with how to implement the components which was the original topic. Please create a new thread for it so we can keep things nice and clean. As a starter you can check the Service Center logs to see who or what is throwing this error.

Greetings,

Vincent

Hi again, Vincent

First, thanks for all the help. I don't know if I need to open a new post, I changed the RepeatTime param and looks like the error it's not happening more.


Bst Regards

Bruno Guidetti

Another point, I checked the questions about the forge component (BackgroundMode Plugin) that you told me and they don't answer the questions, could you help me with this if I open a new Post? I don't even know how to start. If you share with me some documentation explaining how to use the plugin with another plugin like yours, I already have a start point, I'm too new in Outsystems yet.


Bst Regards

Hi Bruno,

I'm sorry but I don't have any experience with that component. But I think you expect an answer to quickly. Almost all Forge component authors are enthusiasts (like me) and do this in there own free time. Alexandre Costa (the author) was online 4 days ago so I wouldn't be surprised if he contacts you within a few days.

Greetings,

Vincent