transistorsoft / flutter_background_geolocation

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

Geofence DWELL not triggering event on IOS #1354

Closed ralon99 closed 3 weeks ago

ralon99 commented 2 months ago

Your Environment

Actual Behavior

On android version the plugin is working as expected though the Headless task mechanism, tested on many devices. On IOS the event is never triggers when the app is terminated.

Steps to Reproduce

1. 2. 3. 4.

Context

On my iphone i can only trigger the event if the phone is connected to the mackbook, if i set the 'geofenceInitialTriggerEntry: ' to 'true' and if i stop and start the service. when the app is installed with the original config and i drive around (much more than the geofence radius) with my phone, it never triggers when getting back inside the geofence.

is there anything wrong or missing in my configuration?

Debug logs

Logs ``` PASTE_YOUR_LOGS_HERE ```
christocracy commented 2 months ago

On IOS the event is never triggers when the app is terminated.

That’s correct. iOS dwell events cannot trigger when the app is terminated.

ralon99 commented 2 months ago

that's very disappointing.. the only need i have from the plugin is geofencing with the dwell option.. will it work as expected with the 'enter' event? even on terminated app?

christocracy commented 2 months ago

will it work as expected with the 'enter' event? even on terminated app?

Terminated: Enter and exit, yes. Dwell no

iOS does not natively support dwell. It’s my own custom implementation using timers. When an iOS app is terminated, your app is completely removed from memory, including the plug-in’s loitering timers. There is no possible solution to this, ever.

ralon99 commented 2 months ago

thanks for the quick reply, i'll try to use the 'enter' as workaround in my app logic

christocracy commented 2 months ago

If your problem is strictly limited to the terminated case, this issue can be closed.

ralon99 commented 2 months ago

hi, i'm reopening the issue because it doesn't seems to work on the 'Enter' event as well.. same configuration as in top thread description, only the geofence creation was changed to this:

return bg.Geofence(
        identifier: arena['uid'],
        latitude: geopoint.latitude,
        longitude: geopoint.longitude,
        radius: arena['alertRadius'].toDouble(),
        notifyOnEntry: Platform.isIOS,
        notifyOnExit: false,
        notifyOnDwell: Platform.isAndroid,
        loiteringDelay: loiteringDelay,
      );

when i set the geofenceInitialTriggerEntry to 'true' and load the application (on first app installation) the trigger of the 'Enter' event is working properly. But, that's about the last trigger that i get.. i took my phone for many rounds in and out the geofence but no trigger occurred. i tried it with terminated app, app in the background and app in the foreground. the only way i could manage to get a trigger is when restarting the service (either stop-start or installing new instance of the app). have you encountered such case? any advices?

christocracy commented 2 months ago

Configure plug-in with debug: true and your geofence with notifyOnExit (just for testing)

do NOT re-enter the geofence until the exit event fires, which typically takes 100-200 meters movement outside the radius.

ralon99 commented 2 months ago

i've tried you suggestion. i got both exit (only when i passed about ~400 meters out of the geofence radius) and the entrance debug notifications. when i went back to the regular code i get no 'Enter' trigger again.. the code i'm using on the trigger is suppose to update Firebase collection with current event name and event time, maybe accessing the DB is the problem? (same function is triggered by the headless event on Android and it's working fine)

christocracy commented 2 months ago

i got both exit (only when i passed about ~400 meters out of the geofence radius) and the entrance debug notifications.

The OS has full responsibility to fire geofence events. If the event fires your .onGeofence listener, that’s all I care about. Everything else is your responsibility.

github-actions[bot] commented 1 month ago

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] commented 3 weeks ago

This issue was closed because it has been inactive for 14 days since being marked as stale.