Question concerning TaifunLocationService extension

I am using LocationSensor extension with get command. I have these block:
image

image

How can I mix extension variable (i.e. LATITUDE) and other variables ? It is correct my blocks ?

I moved your question into its own thread.
My locationservice extension is designed to run in the background, i.e. usually you do not use the LocationChanged event.
Usually you use the background functionality to send location data to a server.

You might want to explain, what you are trying to do and read the documentation. There are several examples which describe how to setup and use the background functionality.
You have to do the setup (i.e. set the RequestText) before starting the service and NOT in the LocationChanged event.

LocationChanged event
Indicates that a new location has been detected. Speed is reported in meters/second.
Note: This event only will fire if the app is up and running.

Taifun

Thank you for shift my post. I try to explain my target:
I need make an app that, in background, send a get command and transmit GPS data to endpoint php. (i.e. send to https://mydomain/endpoint.php?lat=LATITUTE&long=LONGITUDE%time=2024-01-27T17:04:23&note=pippo pluto paperino
I need verifiy if accuracy is below my setting, else not send data. I build yet an app that do it with Kodular LocationSensor, and it run perfectly. Now I would use the same but in background. I hope explained it more clear.

In Kodular locationSensor I use LocationChanged to call Web1.get and send data.
I don’t understand where insert link to php and how read variables (LATITUDE, ecc…)
Please can you do an example with get ?

In the url you insert the link to your script including all your variables

https://mydomain/endpoint.php?lat=LATITUTE&long=LONGITUDE&datetime=DATETIME&note=pippo

From the documentation

the background web functionality is able to convert keywords into their correponding values. The following keywords are available: DATETIME, URIENCODEDATETIME, LATITUDE, LONGITUDE, ALTITUDE, ACCURACY, SPEED, CURRENTADDRESS, URIENCODECURRENTADDRESS and PROVIDER.

for Get requests you do not set the RequestText

Taifun

This is not possible in the extension
Just send all data and add some logic on your server to ignore those records you do not want… you additionally might want to send the accuracy to the server to be able to identify those records

Taifun

Web Block Component :

1-Use Set web.Request Headers block to set request headers.

2-Use web.Post Text block to send your Post request data.
You should use JOIN TEXT BLOCK to send latitude and longitude

latitude=value
&longitude=value

I

3-Use Set web.url block to set your url
https://www.your_domain.com/your_endpoint.php

he is sending a Get request… therefore

Taifun

Thank you so much, now it is more clear

Maybe he’s not sure whether to use : GET or POST . With my suggestion, perhaps he needs change the method.

1 Like

I use get for develop. I build a test code:


What is wrong ?
All authorization are ok, I see Label3 (latitude and longitude) that is updated, the service is started, but gotText do nothing, and backgroundWeb is running but don’t fire. Where is the mistake ?
thank you for help me

I read all documentation and try many test, but I ended ideas

getTest.php?test1234 return the string ?1234, I tested it with browser

unfortunately you are hiding your url parameters, probably there is an error in there?

use a web component together with your url to test

you might want to show us at least everything of the URL starting from the ?

EDIT: you also could send me your test project by email or in a PM, so I can check.

Taifun

Thank you, can I send you by mail ?
My url is more complicated but for this test I have a simple php file
https://mydomain/getTest.php?test=1234
The php file return “?test=1234” in this case. I tested it by browser and it run correctly.
I update with web component and it run perfectly.
I ask: LocationSensor.tag is necessary ?
I sent you an mail

Thank you, I received the mail
what you forgot is to ask for post notification permission, so the service could not be started…
you can do it like this

post

but there is also an issue with the Get request in the background… I now fixed it and published Version 4b of the extension, see also the documentation App Inventor Extensions: Location Service | Pura Vida Apps

Thank you for your tests!

Taifun

Thank you so much, now app run perfectly.
Happy if I has been useful for find bug.

I have a new question for this fantastic extension:
How can I use SPEED variable ? The speed is in m/s, so if I would convert and send it in Km/h I need multiply to 3.6, but I cannot because “SPEED” is not a number.
In future I’d like use speed to change the update position time in smart mode.
i.e. if I am running to 50 Km/h it send every 5 seconds, but if I am walking is sufficient send every 60 second.
Thank’s in advance

:+1:

just do the multiplication on your server
Taifun

Yes, I can multiply on server, but how can I use speed for decide when send data? Only this is a suggest to add functionality. Bye