1

in the near future, my team and I will be developing a website, we will need to collect data via GPS on the phone. In addition, we want to send notifications to users as much as possible. We are currently thinking about the technology stack. As far as it matters we will use python for the backend. And here is the main question: If we decide on a website (which is more likely), how do we collect the location data of a user (latitude and longitude for example) who has accessed the site ON THE PHONE (important) and not on a computer. And what does this look like with sending notifications to him. I would ask you to give me the technologies needed to do this and if you have an idea is the main idea of how it works, but mainly it needs technology. We are completely open to all technologies, so there can be many ideas, we will think through each one reliably. Thank you very much in advance for your help! Greetings!!!

The only thing I have found is to read the location using getCurrentPosition in js, but when I tested this on myself on the computer it showed me to be in a city 200km away.

janluk
  • 33
  • 3
  • The [Geolocation API](https://developer.mozilla.org/en-US/docs/Web/API/Geolocation_API/Using_the_Geolocation_API) is going to be the most reliable way to get a user's location data from a webpage. You will likely see inacurate results on a desktop because they do not have any GPS data and rely on the IP address. Phones (if allowed access) will use GPS to get this data, and you can even use the `enableHighAccuracy` option for more precise results. – EssXTee Nov 16 '22 at 21:06
  • I should also note distinguishing between a phone and any other device is not very reliable. All current methods used to do this can be tricked/fooled by different browsers and devices and so it's typically not recommended to code specific functionality based on whether a user appears to be on a phone or not. Instead, things like [feature detection](https://developer.mozilla.org/en-US/docs/Learn/Tools_and_testing/Cross_browser_testing/Feature_detection) are recommended to determine if something *can* run for a user and executing compatible code. Though this may not affect you at all... – EssXTee Nov 16 '22 at 21:08
  • @EssXTee Thank you very much, the GPS issue is solved, but what about notifications? – janluk Nov 17 '22 at 08:47
  • I don't know a whole lot about the [Notification API](https://developer.mozilla.org/en-US/docs/Web/API/Notifications_API) but this is essentially what you would use to send notifications. It works a bit differently for mobile but [this answer](https://stackoverflow.com/a/31787926/2339619) on StackOverflow provides a good example of a notification that works in a mobile browser (at least for android). I think that's a good place to start. – EssXTee Nov 17 '22 at 13:32

0 Answers0