1

The Question

How can I track a user's movements via ESRI's JavaScript API in a web browser when their phone is shut/locked?

This would ideally work for all web browsers (i.e. Android and Apple versions of Chrome, Firefox etc..). However, any platform specific suggestions would also be very welcome.


What I've tried

I've thought about playing a video on loop (hidden) on the maps page so the phone doesn't automatically lock, keeping the browser open. However, this would potentially be a huge waste of battery for users and false clicks may get recorded while in the user's pocket so I'd like to avoid this solution if possible.


Some more context:

I'm developing a charity webapp for a community group trying to track their movements when out on patrols which can last between 30 mins and a couple of hours.

The tracking should work similarly to strava and should record their movements at regular intervals (I've decided on every 10 secs but this is somewhat arbitrary).

I've already written the majority of the app including the backend/database code and deployment scripts so I really wouldn't want to start again creating a stand-alone Android and iOS app.

1
  • As awesome as a titanium shovel might be, you can't use it to thread a needle. The code to obtain and transmit location can't be more than a page or two, but it has got to be a service app that can run during screen lock. And the code is likely very different on Apple than Android.
    – Vince
    Commented Apr 15, 2020 at 10:45

1 Answer 1

1

I'll add this answer (mostly for someone who happens upon your question, I dont think it'll provide you the answer you want).

The answer to your question will be at the device level, assuming it's possible. I don't think this is much of a GIS question -- how do I keep a webpage running when the phone is sleeping? You may want to try on another stack site.

For the task at hand, the official Esri way would be to use the Esri native app, Tracker for ArcGIS. The Esri Tracker app puts the end user in full control of tracking. They need to turn it on, simply having the app installed on your phone doesn't opt you in. I'll point out there could be some serious morale and ethical implications to having a website you visit track your location even after you sleep your phone. Unless of course you build in all the buttons and announcements of what its doing.

Not the answer you're looking for? Browse other questions tagged or ask your own question.