How do I make an app where a user can make post in specific areas only

I want to create an app that allows users make post in a certain or specific radius maybe 1km - 5km this would let only users of the app within that radius view the post using react native or expo please any help would be appreciated thanks. once a user is outside the set radius or range of the post the user can not see the post created

Hi

Assuming you know the latitude and longitude of the place that you want the users to be close to, you would need to periodically get the user’s location and presumably set some state to keep track of it. Then when the user is within the circle, you can enable the buttons/screens/etc. that allow the user to fetch the posts that they should be able to see. When the user moves outside of the circle you would have to hide the screen with those posts or something like that.

In order to calculate the distance from the user to the location that you want them to be close to, there are several different JavaScript libraries that can calculate this. e.g. I just found these by searching for npm geolocation distance:

https://www.npmjs.com/package/geolocation-distance

and there are others.

Just bear in mind that especially with emulators/simulators it is possible for a user to spoof their location. Also, GPS is not always accurate.