transistorsoft / flutter_background_geolocation

Sophisticated, battery-conscious background-geolocation & geofencing with motion-detection
https://www.transistorsoft.com/shop/products/flutter-background-geolocation
Other
640 stars 236 forks source link

Help Geofence error #407

Closed luisbazan closed 3 years ago

luisbazan commented 3 years ago

Hi,

This a quick question, I'm getting an error in some devices when the geofence is added. According to the log, I do see this message:

09-21 18:06:48.987 DEBUG [TSLocationManager locationIsInvalid] Distance from last location: 20.905018, apparent speed: 1.0452509 09-21 18:06:48.988 DEBUG [TSLocationManager calculateMedianAccuracy] Median accuracy: 4.63 09-21 18:06:48.989 DEBUG [TSLocationManager incrementOdometer] Odometer: 1916.0944 09-21 18:06:49.003 INFO [b persist] ✅ INSERT: 75126cc9-768f-48d4-aaac-00639e1fd06b 09-21 18:06:49.005 DEBUG [AbstractService a] ⚙️︎ finish TrackingService [eventCount: 0, sticky: true] 09-21 18:06:49.129 ERROR [TSGeofenceManager$f$b onFailure] ⚠️ Failed to add geofences: 1001: 09-21 18:07:08.031 DEBUG [AbstractService a]

any idea? what does mean 1001? how to get more details of the issue?

I'm using this configuration:

logLevel: bg.Config.LOG_LEVEL_VERBOSE,

Regards

christocracy commented 3 years ago

https://developers.google.com/android/reference/com/google/android/gms/location/GeofenceStatusCodes#GEOFENCE_TOO_MANY_GEOFENCES

christocracy commented 3 years ago

Curious. The plugin shouldn’t allow “too many” geofences to be added.

Can you show me the result of getGeofences() on that device?

luisbazan commented 3 years ago

thank so much

luisbazan commented 3 years ago

umm, that's strange I've reviewed and I have devices with more than 100 records (ex:125) and it works but the device which failed just has 75 records.

I didn't know that there was a limit of geofences so I'm going to add this validation in my code. image

christocracy commented 3 years ago

The plugin puts a cap of 99 geofences, reserving 1 for its “stationary geofence”.

It’s clearly documented in Android docs that the limit is 100.

christocracy commented 3 years ago

When I say “puts a cap of 99”, I mean actively monitoring 99. The plugin’s “infinite geofencing” system kicks in at that point, to automatically monitor only those within geofenceProximityRadius.

That has nothing to do with a device failing on 75.

Are there other plugin’s which might be activating geofences in your app?

luisbazan commented 3 years ago

No, there is not. I'll need to do some research here. just a question, what is the better way to remove a geofence data when entry and exit record is already existing itself? I need to remove it manually, right? or is there any option in the plugin to do that?

christocracy commented 3 years ago

what is the better way to remove a geofence data when entry and exit record is already existing itself

luisbazan commented 3 years ago

Let me explain to you well, I need to add more 100 geofences by day for tracking (ex: 150), but I am not able to do that due to the max geofences is 100. so I thought to create an algorithm that allows us to remove from the geofences all the records have been already visited(enter and exit) and add the next records(60). I wonder if it is a good idea to add this logic into the onGeofence event but it would not work if the app is closed. Perhaps there is some option in the plugin that allows doing that automatically (remove all geofence that was visited of the list).

christocracy commented 3 years ago

I need to add more 100 geofences by day for tracking (ex: 150), but I am not able to do that due to the max geofences is 100.

The plugin has an "infinite geofencing system". You can add any number of geofences and the plugin will automatically activate the closest 100 within Config.geofenceProximityRadius. See API docs:

luisbazan commented 3 years ago

Thx