[PAID] 📍 Location Service Extension

I removed your project...

Sorry, you can't post a project, which includes a paid extension in the community... this is against my t&c...

It looks like you need help with your project and you are in a hurry, so yo are not able to follow the documentation...

Please contact me by mail, send me your project and I can take a look at it... please be ready to transfer a small amount to cover my time for this..

Alternatively post a screenshot of your relevant blocks here...

You really should spend some time to read and understand the documentation and play around with the example project... to do something in the background is working on another level...

Taifun

Please see my blocks below. As mentioned it's more of an issue that I don't fully understand what's needed to be done.


If you have a closer look that would be appreciated

you blocks are exactly the same as previously...
you already found out yourself, this will not work like this if the app is in the background
as already mentioned earlier

Also your Clock events will not fire and you will not be able to draw something in the background...

You have to do it like this: while the app is in the background, the location data will be stored in TinyDB... additionally you can send your Post requests in the background to somewhere... as an example see the IFTTT setup... just adjust it to your needs and use the keywords as described in the documentation...

Background web properties

The following properties are used to configure the background web functionality to send a request. The following requerst methods are available: GET, POST, PUT, DELETE, PATCH, HEAD and OPTIONS. Also 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


you have to setup the web background functionality before starting the locationservice

Later when you start again your app, then read all the stored data from TinyDB and draw on the map... my example project shows you how to draw all the stored coordinates on the map, see the ListPicker.AfterPicking event there App Inventor Extensions: Location Service | Pura Vida Apps

I hope this helps to get you starting...

Taifun

Suggestion:

There should be a blacklist of paid extensions NOT allowed to be posted here. So something like what is already the case when an APK is posted (which is not allowed/possible).

Any app developer who offers paid extensions can enter their extensions in this list.

Perhaps the AI2 team can consider this option.

3 Likes

Ok so I've looked at the example blocks provided and started afresh. this is what I've got so far. My google sheet says it was updated seconds ago so i believe it's trying to post something, but nothing shows up. Please can you tell me what's missing in the simplest way as like I've already mentioned i don't understand the example at


all.

some observations

  1. first do the setup, then start the service
  2. also move the notifier down (see arrow) and in case no GPS is enabled, show a notifier which tells the user to enable GPS
  3. also it might be a good idea to set the request header as @SteveJG showed you in his example here HOW TO: use LocationService extension with a GoogleSpreadsheet to record real time locations while the app is in the background - #7 by SteveJG
  4. it does not make much sense to set the bckground web property first to false and later to true... only set it to true
  5. use a reasonable value for the distance interval... this property determines the minimum distance interval, in meters, that the sensor will try to use for sending out location updates... 0 does not make sense... try to first use the default value of 5... and after you got it running, then later you can adjust it to your needs...
  6. it would be wise to use the ErrorOccured event... see also Q2 here App Inventor Extensions: Location Service | Pura Vida Apps
  7. as general recommendation to test your POST method: as test use the web component to send some test values to your Google spreadsheet to find out the correct blocks for the POST method... after you got this working then setup the background web functionality accordingly...

Taifun

Thank you, I've tried the above suggestions and it doesn't work. The app goes to start the background process then closes, it says the app closed due to a bug. Any ideas?

some observations and suggestions

  1. we already talked about clocks... it is not a good idea to start the locationservice several times... in the latest screnshot you are using again clock components... Clock_In starts Clock2... My guess is, Clock2 will be started again and again by Clock_In... repeatedly starting the locationservice might be an issue... let me suggest you to start it only once... my suggestion is to move all the setup blocks into the Screen.Initialize event and use a button to start the service

  1. it would be wise to use the ErrorOccurred event and display any errors for example in a label... see also Q2 here App Inventor Extensions: Location Service | Pura Vida Apps as test disable the MoveTaskToBackground methods to find out if there are any errors reported
  2. as general recommendation to test your POST method: as test use the web component to send some test values to your Google spreadsheet to find out the correct blocks for the POST method... did you get this running successfully? can you show the blocks for this test?
  3. the Web.Post method inside the LocationChanged event does not make sense... if the blocks were correct (they are not, because only the locationservice in the background is able to convert the keywords), you would post the information twice to your Spreadsheet, first from the extension running in the background and then again in the LocationChanged event... just remove the PostText block completely
  4. to get more information about the runtime error you are experiencing, use logcat and post the logcat report as text file here, see also Capturing Device Logs using adb logcat

Taifun

Version 3 of the Locationservice extension has been released App Inventor Extensions: Location Service | Pura Vida Apps

SDK31 update: FLAG_IMMUTABLE for pending intents added, property MaxTimeBeforeShutdown in minutes added, RequestMethod helper added, bug fix for empty request header

setMaxTime

requestMethod

Thank you @SteveJG and @Samuel_Dutton for your tests!
Taifun

1 Like

Hi Taiifun as mentioned my app uses a geofence that once you leave the fence and return to it, it will post to my Google sheet, I call procedures to only post once to the sheet instead of multiple times and to reduce the amount of blocks in location changed event. I was wondering if this logic can be done in the background.

first of all great, that you got it running now

Thank you guys for all the help. I've got my app to post to my Google sheet whilst maintaining my apps purpose. The error was with the Google script.

unfortunately this is not possible using the locationservice extension, but what about a server solution? You could write a Google Apps Script to delete the rows from the spreadsheet you do not want using some logic...

Taifun

What about some code like this? This is not THE solution but an idea you might work with.

It calculates distance (miles) between your present coordinates and a destination(lat2,long2). It is sort of a geofence. When you approach a destination it posts distance to that location as you get closer. I tested this and it works to post the accuracy and the distance.

If you modify add a script to your spread sheet, you might be able to only post when the distance is less than 1 mile. Another idea is to RequestMethod immediately preceding the RequestText (I haven't tried this).

Good luck.

1 Like

Remember, the LocationChanged event of the extension only fires if the app is NOT in the background...
also the setup (for example setup of the RequestText) needs to be done before starting the service...

but you could use the formula from Steve and calculate the distance in the spreadsheet after passing the current lat and long... the destination lat and long could be provided for example as variable in the Google Apps Script

Taifun

Thank you both. It's given me an idea.

Wow! Great extension!!! I will buy it soon

I'm using mysql, but I want only one data to be entered into mysql database and use the UPDATE code block to change that data automatically with location change.
how do?

Your blocks look fine...
As test you can use the web component to find out, if your update statement works fine
Also you might want to use Do it to debug your query to find out, if the number is correct...
And while using the extension it helps to use the ErrorOccurred event to display any errors in a label just in case

Taifun

Thank you @Taifun
I will try it

The previous project was buildable, but after I added the extension location service an error occurred.
Please help me

The location service test project builds fine, which means, it is something else in your project...

Send me your previously working project file by email or PM and I will check

Taifun
PS: as you know, posting a project in the community which includes paid extensions is not allowed....