Search code examples
androidangularjsionic-frameworkgpsgeolocation

Detect movement of two phones in an area?


A mobile app I'm designing with Ionic requires that I (backend) or another user (phone 1) am able to detect movement of another user (phone 2).

Usage scenario:

  1. I want to set a landmark/beacon (latitude + longitude) at my current location, and log these coordinates.
  2. Once I leave my current position ( position of the landmark ), I want to be able to confirm when a specific user moves to my landmark.

It'd require an accuracy / granularity of about 10 feet. I've already looked at things like p2pkit.io and ngGeolocation, but neither seem accurate enough. Battery life is not a concern, as this particular part of the app will be used very briefly.

Any and all help or insight is greatly appreciated.


Solution

    • ngGeolocation has an options parameter (the third one), where you can set "enableHighAccuracy" to true. This is very accurate, depends on your device.
    • For background geo location, I can recommend cordova-background-geolocation-services by pmwisdom (link to GitHub). It makes geolocation work in the background, and has some more neat features for battery efficiency (e.g. geolocation won't be sent if device hasn't moved X feet). Also since you're using android, this specific background addon does not require any payment (unlike others out there).