What’s the best plugin for tracking people’s location live… like in cab apps?
So far I found the only app wrapper that advertises Background geolocation (so it continues to track with the screen off) is https://www.buildnatively.com , the app running on the device sends a webhook to your app with in the interval you pick when you triggered the start tracking action. I have tested it a little bit myself and you have to be careful not to poll for location too often or else the user’s phone will kill the app for battery savings.
If the screen will be on the whole time you can use the native Bubble Current geographic position
data source, and do some kind of loop to save that to your database every X minutes
use "do every x " consumes too many workflow units
That event in itself won’t consume any WUs, its the actions you run from that that will determine usage. No matter what you will be creating a database entry every time you want to save their location
I had already tried this method to locate live, it worked well but it was because of the WU that I deactivated… I did “do every 5s”… I’m going to try for 1 minute to see what it will do
Yea 1 min or more would be better. You could also put some logic so on the device you store the previously created entry, then when you go to save the next one if it’s within 0.2 miles of the previous one don’t save it yet, but update the previous one’s “End time” with a new date so each location has a time range
So if a taxi driver sits for 10 minutes you don’t create 10 entries Just one from 1:30 to 1:40 in same location
thank you for your advice, which is very useful… don’t hesitate to share other information if you can.
@tylerboodman do you have an implementation guide for setting up background location tracking please?
I’ve searched the Bubble.io forum, YouTube and read the natively docs but there is nothing which goes through the setup specifically.
My use case: I have a feature only used by some users where they will need to enable background location services on a given page. Once enabled we will check their location against a physical location to allow them to “Check In”. There will need to be regular location checks to ensure that they are still present and if not, they will be “checked out” either manually or by the system.
I’m using the Natively plugin 2.13.9. I’ve setup the webhook, enabled geolocation in the Natively dashboard and verified the webhook. I’ve also created a new Android build.
On the page where location is required, I’ve setup an event when successful to start the background service (call the API I’m assuming) with the user ID in the response and show me a label for now, to test it’s working. However, nothing seems to happen.
I have two problems:
- There is no guidance on the step by step implementation (that I can find). Please see screenshot below.
- I don’t know how to test it because this workflow is in Development but the new build is the Live version, so even if I install the APK on my device, it’s showing Live not Dev. This also isn’t working in the browser for test purposes.
Please can you help with these 2 things?
Hey @chris.anderson
See if this helps, if not let me know and when I have some more time later I can explain the exact workflow
-
The background service needs to be started by something like a button. Then if that action was successful it triggers the Success event. From the event you would then show the success alert. Right now it seems that event would never trigger
-
For mine I put a prefix in front of the unique identifier indicating if it’s coming from live or dev like this:
So in a live app for example it would send
version-live_1709097745645x912507735293558800
Make a backend workflow that receives the webhooks. In the Natively dashboard where you provide the webhook URL I have it going to Dev first, like this:
https://[appname]/version-test/api/1.1/wf/[workflow name]
then via API connector do a POST to your own app going to live or dev depending on that prefix. So it would go to this endpoint:
https://[appname]/[request identifer:split by "_" :first item]/api/1.1/wf/[2nd workflow name]
Thanks @tylerboodman really appreciate the help! Good thinking on the URL and API, etc! I’ll do that shortly.
For now, I’m just trying to get it started. So I’ve created a button which now “starts” the background service as an action… but nothing happens. I suspect this is because I’m testing in the browser rather than within the native app? As I’m not even prompted for location permissions.
I’m assuming this is the case because when I “Save and verify” the webhook in the Natively Dashboard, I receive a JSON payload (I can see in the logs) correctly. However, when I use the button to start the background service in the app, the webhook doesn’t receive anything.
So if I’m correct with the above and it’s just not working in the browser, how do we test using the native app? Even if I rebuild and install the APK on my phone, it’s based on Live and I don’t want to deploy these changes to Live yet. If I create a new Natively App based on the Test environment, Background Location doesn’t work in the Natively Preview app.
Are you able to advise please:
- How I can dev / test this before deploying to Live?
- What is the implementation flow required?
a) Setup a way to obtain location permission - I can’t find a documented way to do this
b) Start background service
c) Implement my app logic to compare location received, etc
d) Add a way to stop service
e) Error handling
I’ve also sent a query to Natively but no response as yet. Bubble.io Facebook group also wan’t helpful.
Thanks in advance!!!
@chris.anderson
Yes it has to be tested from the app. That’s because the wrapper is listening for the trigger from within the app then the wrapper/native portion is handling the webhook-sending.
I put a yes/no field on the user if they are allowed to “Go to dev” and I have a button that is only visible/works if the user has that as “yes”.
So one specific account I use for testing I log in on the live app then have it redirect me to the dev version.
After you start background location from within the Natively-wrapped app it will prompt the user to allow location sharing on their device .
Any workflow that requires background tracking needs to be triggered from the “Background tracking success” event
The there’s a “Stop background location” action to stop it
Error handling will be triggered from the “Background tracking failed” event, it should have the error message with it to either show the user or email developers, etc
Ah very clever! Thanks again for the quick and detailed responses. I’ll give this a go.
Thanks again!
Hey @tylerboodman, I’ve been away on holiday so just coming back to this and I’m struggling with this part:
“So one specific account I use for testing I log in on the live app then have it redirect me to the dev version.”
I have a dedicated user who can see a special button which activates the location service. However, I’m not sure how to get this button to redirect to the Dev version as the “Go to page” actions obviously just go to Live and if I open an external page it uses the browser rather than the app. I’ve tried sending data and manipulating the URL but no joy. I also have a feature which redirects the user to their home page if they go to the login page and are already logged in… which may be causing a conflict here but I’m unsure.
Are you able to advise or send a screenshot (removing any sensitive info) of the actions used to redirect to the dev version within the app itself please?
TIA!