Geofence Confusion

Currently confused about implementing the geofence plugin …

Maybe I’m just missing the obvious, but I thought that the geofence plugin worked all of the time as a standalone? Whatever I try it always needs something like Google Maps to be actively monitoring the device location, in which case my notifications are sent. Without this I get nothing.

Perhaps it’s so obvious that there’s no need for this to be in the documentation?

So. Do I also have to have the geolocation plugin actively watching the device location in order for the geofence plugin to know when a geofence boundary has been crossed? Does the geofence plugin not watch the location itself? Or maybe this is a quirk of emulators (both Android and IOS). I get the same thing on a real IOS device when tethered and using the ‘debug’ menu in Xcode to fake the location.

Hopefully someone can just clear my confusion up for me. If I have to have the geolocation plugin active (and I guess background-geolocation for when the app is in the background) in order for the geofence plugin to detect when a boundary is crossed then so be it. It’s just that the documentation makes no mention of this and seems to indicate that there are no additional requirements other than itself.

Did you figure this out?

I use geolocation and background-geolocation to monitor current position. This seems to be the way to trigger the geofence plugin so it detects a boundary being crossed. Working well in my app on both IOS and Android, anyway, so I’m happy.

One annoying headache to watch out for is the general Cordova plugin annoyance when versions of the Google Play Services for Android (which the geofence plugin requires) don’t match the version in another plugin you may be using (eg push notifications) which breaks your Android app. I ended up manually editing the plugin XMLs in my project to ensure that the version used was the same in all. Eliminated some very annoying compilation errors.

So you run them both at the same time?

How did you store the geofence locations in your app, and compare/track them?

I’ve got some questions and I really appreciate that you answered so quickly!

Not really sure what it is you are wanting to do. In my app the only thing I’m interested in is detecting when a geofence is crossed. To do this there’s no need to store or track the location. You’d only really do something like that in a driving app or something like that.

The background-geolocation plugin saves locations to sqlite on the device if configured, I believe. See the documentation for that plugin with regards to that. As I say, in my app I do not keep a record of the device location history so set the ‘maxLocations’ to 0