Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

addGeofences method not working #16

Open
pablog9 opened this issue Jul 5, 2020 · 1 comment
Open

addGeofences method not working #16

pablog9 opened this issue Jul 5, 2020 · 1 comment

Comments

@pablog9
Copy link

pablog9 commented Jul 5, 2020

I have flutter_background_geolocation + background_geolocation_firebase correctly working (Android) with locations:
My setup looks like this:

BackgroundGeolocationFirebase.configure(BackgroundGeolocationFirebaseConfig(
  locationsCollection: "/vehicles/${_vehicle.id}/locations",  
  geofencesCollection: "/routes/${_currentRoute.id}/geofences",  
  updateSingleDocument: false
));

Locations are working as expected creating a subcollection inside current vehicle document.

Now I am trying to add geofences, adding multiple geofences at once (2 for this example: id: 1, id: 21) to a list:

List<bg.Geofence> geofences = new List<bg.Geofence>();
// foreach step in steps
Bg.Geofence geofence = bg.Geofence(
    identifier: step.index.toString(),
    radius: 200,
    latitude: step.latitude,
    longitude: step.longitude,
    notifyOnEntry: false,
    notifyOnExit: false,
    notifyOnDwell: true,
    loiteringDelay: 30000,
    // 30 seconds
    extras: {"type": step.type});
geofences.add(geofence);
// end foreach
if (geofences.isNotEmpty)
  bg.BackgroundGeolocation.addGeofences(geofences);

But nothing happens, subcollection is never created and these logs are shown:

I/TSLocationManager( 5389): [c.t.l.data.sqlite.GeofenceDAO destroy]
I/TSLocationManager( 5389): ✅ 1
I/TSLocationManager( 5389): [c.t.l.data.sqlite.GeofenceDAO create]
I/TSLocationManager( 5389): ✅ 1
I/TSLocationManager( 5389): [c.t.l.data.sqlite.GeofenceDAO destroy]
I/TSLocationManager( 5389): ✅ 21
I/TSLocationManager( 5389): [c.t.l.data.sqlite.GeofenceDAO create]
I/TSLocationManager( 5389): ✅ 21
D/TSLocationManager( 5389): [c.t.l.g.TSGeofenceManager c] ℹ️ Persist monitored geofences: []

Why are there sqlite references if I am using the firebase version?

@christocracy
Copy link
Member

christocracy commented Jul 6, 2020

But nothing happens, subcollection is never created and these logs are shown:

Those logs are normal.

Why are there sqlite references if I am using the firebase version?

Because the plugin stores ADDED geofences in its SQLite database. This is the collection of geofences you've asked the plugin to monitor.

I think you're confused about added geofences vs geofence events.

When a geofence EXIT / ENTER event occurs, then the plugin will post that event to Firebase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants