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

[Help Wanted]: Polygone geofencing event:EXIT is not trigger in Android #1411

Open
2 of 3 tasks
ArthurKim19971001 opened this issue Jan 27, 2025 · 17 comments
Open
2 of 3 tasks

Comments

@ArthurKim19971001
Copy link

Required Reading

  • Confirmed

Plugin Version

4.16.6

Mobile operating-system(s)

  • iOS
  • Android

What do you require assistance about?

The circle geofencing is working well as I expect - get the events from the trigger about Enter and Exit. But, the ploygon geofecing is not able to listen 'Exit' event. It is working after reloading the app only to get Exit event from ploygon geofence.

How do I listen the 'Exit' event directly without reloading the app as the circle geofence one?

[Optional] Plugin Code and/or Config

static final bg.Config _config = bg.Config(

    desiredAccuracy: bg.Config.DESIRED_ACCURACY_HIGH,
    distanceFilter: 20.0,
    disableElasticity: true,
    stationaryRadius: _stationaryRadius,
    geofenceProximityRadius: 20000,
    geofenceInitialTriggerEntry: true,
    stopOnTerminate: false,
    startOnBoot: true,
    logLevel: Environment.geofenceLogLevel,
    logMaxDays: Environment.logMaxDays,
    disableLocationAuthorizationAlert: true,
    enableHeadless: true,
    stopTimeout: 10,
    heartbeatInterval: 60,
    maxDaysToPersist: 1,
    persistMode: bg.Config.PERSIST_MODE_GEOFENCE,
    locationTemplate:
        '{"timestamp":"<%=timestamp%>","accuracy":"<%=accuracy%>","activityType":"<%=activity.type%>","activityConfidence":"<%=activity.confidence%>","event":"<%=event%>"}',
    geofenceTemplate:
        '{"identifier":"<%=geofence.identifier%>","timestamp":"<%=timestamp%>","action":"<%=geofence.action%>","accuracy":"<%=accuracy%>","activityType":"<%=activity.type%>","activityConfidence":"<%=activity.confidence%>","event":"<%=event%>"}',
    url: "${Environment.apiBaseUrl}/api/visitor_notifications/location",
    notification: bg.Notification(
      title: "Check-in locations nearby",
      text: "Tap to open app",
      channelName: "Locations",
      smallIcon: "drawable/ic_stat_name",
      largeIcon: "drawable/ic_stat_name",
    ),
  );

  Future<bg.Config> _getConfig() async {
    final useHighAccuracyGeofences = _settingsBox.get(
      SettingsBox.useHighAccuracyGeofences,
    );

    final String baseUrl = await LocalPersistence.getBaseUrl();

    if (baseUrl.isNotEmpty) {
      _config.url = "$baseUrl/api/visitor_notifications/location";
    }

    if (useHighAccuracyGeofences == true) {
      _config.geofenceModeHighAccuracy = true;
    }

    return _config;
  }

bg.BackgroundGeolocation.ready(await _getConfig());

[Optional] Relevant log output

----------------Log about circle geofence exit events trigger------------------------------
D/TSLocationManager( 2079): [c.t.l.service.AbstractService a]
D/TSLocationManager( 2079):   🎾  start [GeofencingService  startId: 1, eventCount: 1]
W/TSLocationManager( 2079): [c.t.l.g.TSGeofence$Builder build]
W/TSLocationManager( 2079):   ⚠️  Geofence radius: 100.0:  recommended geofence radius is >= 150.0meters
W/TSLocationManager( 2079): [c.t.l.g.TSGeofence$Builder build]
W/TSLocationManager( 2079):   ⚠️  Geofence radius: 96.0:  recommended geofence radius is >= 150.0meters
D/TSLocationManager( 2079): [c.t.l.g.TSGeofenceManager e] ℹ️  Persist monitored polygons: {}
V/TSLocationManager( 2079): [JNI geofencing] clearPolygon de01e686-d7b8-4794-8c92-06c268a2b844
I/TSLocationManager( 2079): [c.t.l.s.GeofencingService a]
I/TSLocationManager( 2079): ╔═════════════════════════════════════════════
I/TSLocationManager( 2079): ║ Geofencing Event: EXIT
I/TSLocationManager( 2079): ╠═════════════════════════════════════════════
I/TSLocationManager( 2079): ╟─ e8093f31-0e7d-4650-9d63-cb715744e531
I/TSLocationManager( 2079): ╟─ EXIT containing geofence of Polygon: de01e686-d7b8-4794-8c92-06c268a2b844
I/TSLocationManager( 2079): ╚═════════════════════════════════════════════
W/TSLocationManager( 2079): [c.t.l.g.TSGeofence$Builder build]
W/TSLocationManager( 2079):   ⚠️  Geofence radius: 100.0:  recommended geofence radius is >= 150.0meters
I/TSLocationManager( 2079): [c.t.l.logger.TSLog log]
I/TSLocationManager( 2079):   ℹ️  [GeofenceService enqueue] [GeolocationEvent name: location, data: [Location {odometer: 0, activity: {confidence: 100, type: still}, mock: true, extras: {}, battery: {level: 1, is_charging: true}, uuid: d12808be-8999-42ab-b5e4-77384f9e6282, age: 119, coords: {altitude: 0, heading: -1, latitude: -36.72694519795622, accuracy: 0.01, heading_accuracy: 0.1, altitude_accuracy: 0.1, speed_accuracy: 0.01, speed: -1, age: 125, longitude: 174.71894804388285, ellipsoidal_altitude: 0}, is_moving: false, timestamp: 2025-01-27T23:27:10.472Z}], id: ed25e323-f34a-4939-ba74-989dffe0c94e, isHeadless: false]
I/TSLocationManager( 2079): [c.t.l.d.s.SQLiteLocationDAO persist]
I/TSLocationManager( 2079):   ✅  INSERT: 26cc3a0d-6ab5-444b-adb0-3e9533f5a6a9
I/TSLocationManager( 2079): [c.t.l.http.HttpService flush]
I/TSLocationManager( 2079): ╔═════════════════════════════════════════════
I/TSLocationManager( 2079): ║ HTTP Service (count: 1)
I/TSLocationManager( 2079): ╠═════════════════════════════════════════════
D/TSLocationManager( 2079): [c.t.l.service.AbstractService a]
D/TSLocationManager( 2079):   ⚙️︎   FINISH [GeofencingService startId: 1, eventCount: 0, sticky: false]
I/TSLocationManager( 2079): [c.t.l.logger.TSLog log]
I/TSLocationManager( 2079):   ℹ️  [GeofenceService enqueue] [GeolocationEvent name: geofence, data: [GeofenceEvent identifier: e8093f31-0e7d-4650-9d63-cb715744e531, action: EXIT, timestamp: 2025-01-27T23:27:10.602Z], id: 30c4b080-9b0b-45d4-8115-8193bcbb6f8f, isHeadless: false]
I/TSLocationManager( 2079): [c.t.l.u.BackgroundTaskManager$Task start] ⏳ startBackgroundTask: 49
I/TSLocationManager( 2079): [c.t.l.u.BackgroundTaskManager$Task start] ⏳ startBackgroundTask: 50
I/TSLocationManager( 2079): [c.t.l.logger.TSLog log]
I/TSLocationManager( 2079):   ℹ️  [GeofenceService _runBackgroundTask] [GeolocationEvent name: location, data: [Location {odometer: 0, activity: {confidence: 100, type: still}, mock: true, extras: {}, battery: {level: 1, is_charging: true}, uuid: d12808be-8999-42ab-b5e4-77384f9e6282, age: 119, coords: {altitude: 0, heading: -1, latitude: -36.72694519795622, accuracy: 0.01, heading_accuracy: 0.1, altitude_accuracy: 0.1, speed_accuracy: 0.01, speed: -1, age: 125, longitude: 174.71894804388285, ellipsoidal_altitude: 0}, is_moving: false, timestamp: 2025-01-27T23:27:10.472Z}], id: ed25e323-f34a-4939-ba74-989dffe0c94e, isHeadless: false]
I/TSLocationManager( 2079): [c.t.l.u.BackgroundTaskManager$Task stop] ⏳ stopBackgroundTask: 49
D/TSLocationManager( 2079): [c.t.l.d.s.SQLiteLocationDAO first]
D/TSLocationManager( 2079):   ✅  Locked 1 records
I/TSLocationManager( 2079): [c.t.l.http.HttpService a]
I/TSLocationManager( 2079):   🔵  HTTP POST: 26cc3a0d-6ab5-444b-adb0-3e9533f5a6a9
I/WM-WorkerWrapper( 2079): Worker result SUCCESS for Work [ id=64eb394c-2ed0-4bf5-bd90-cc5ac07feed9, tags={ com.transistorsoft.locationmanager.util.BackgroundTaskWorker } ]
I/TSLocationManager( 2079): [c.t.l.u.BackgroundTaskManager$Task start] ⏳ startBackgroundTask: 51
I/TSLocationManager( 2079): [c.t.l.logger.TSLog log]
I/TSLocationManager( 2079):   ℹ️  [GeofenceService _runBackgroundTask] [GeolocationEvent name: geofence, data: [GeofenceEvent identifier: e8093f31-0e7d-4650-9d63-cb715744e531, action: EXIT, timestamp: 2025-01-27T23:27:10.602Z], id: 30c4b080-9b0b-45d4-8115-8193bcbb6f8f, isHeadless: false]
D/TSLocationManager( 2079): [c.t.l.service.AbstractService f]
D/TSLocationManager( 2079):   ⚙️︎  GeofencingService.stopSelfResult(1): true
D/TSLocationManager( 2079): [c.t.l.service.AbstractService onDestroy]
D/TSLocationManager( 2079):   🔴  GeofencingService stopped
I/TSLocationManager( 2079): [c.t.l.http.HttpService$f onResponse]
I/TSLocationManager( 2079):   🔵  Response: 200
D/TSLocationManager( 2079): [c.t.l.d.s.SQLiteLocationDAO destroy]
D/TSLocationManager( 2079):   ✅  DESTROY: 26cc3a0d-6ab5-444b-adb0-3e9533f5a6a9
I/TSLocationManager( 2079): [c.t.l.logger.TSLog log]
I/TSLocationManager( 2079):   ℹ️  [GeofenceService enqueue] [GeolocationEvent name: http, data: {location: {action: EXIT, identifier: e8093f31-0e7d-4650-9d63-cb715744e531, httpVersion: 1, event: geofence, timestamp: 2025-01-27T23:27:10.472Z, accuracy: 0.01, activityConfidence: 100, device: samsung SM-G977N, type: 0, siteId: 14641, terminalId: null}}, id: 9039f956-3816-4385-8048-2886a04ae65f, isHeadless: false]
I/TSLocationManager( 2079): [c.t.l.u.BackgroundTaskManager$Task stop] ⏳ stopBackgroundTask: 50
I/WM-WorkerWrapper( 2079): Worker result SUCCESS for Work [ id=e5f2124a-ec31-49de-9ce7-71ac5045cff5, tags={ com.transistorsoft.locationmanager.util.BackgroundTaskWorker } ]
I/flutter ( 2079): Exit ignored -  not checked in.
I/TSLocationManager( 2079): [c.t.l.u.BackgroundTaskManager$Task stop] ⏳ stopBackgroundTask: 51
I/WM-WorkerWrapper( 2079): Worker result SUCCESS for Work [ id=8b848ca6-0221-41d8-b4f2-6b995c3770d2, tags={ com.transistorsoft.locationmanager.util.BackgroundTaskWorker } ]
I/TSLocationManager( 2079): [c.t.l.u.BackgroundTaskManager$Task start] ⏳ startBackgroundTask: 52
I/TSLocationManager( 2079): [c.t.l.logger.TSLog log]
I/TSLocationManager( 2079):   ℹ️  [GeofenceService _runBackgroundTask] [GeolocationEvent name: http, data: {location: {action: EXIT, identifier: e8093f31-0e7d-4650-9d63-cb715744e531, httpVersion: 1, event: geofence, timestamp: 2025-01-27T23:27:10.472Z, accuracy: 0.01, activityConfidence: 100, device: samsung SM-G977N, type: 0, siteId: 14641, terminalId: null}}, id: 9039f956-3816-4385-8048-2886a04ae65f, isHeadless: false]
I/flutter ( 2079): Exit ignored -  not checked in.
I/TSLocationManager( 2079): [c.t.l.u.BackgroundTaskManager$Task stop] ⏳ stopBackgroundTask: 52
I/WM-WorkerWrapper( 2079): Worker result SUCCESS for Work [ id=82626642-f3f0-4f66-959e-7de0d70c8a4f, tags={ com.transistorsoft.locationmanager.util.BackgroundTaskWorker } ]
--------------------------------------------------------------------------------------------------

-----------------------------Log about ploygon geofence exit events trigger-----------------------
I/TSLocationManager( 2079): [c.t.l.scheduler.ScheduleEvent a]
I/TSLocationManager( 2079): ╔═════════════════════════════════════════════
I/TSLocationManager( 2079): ║ ⏰ OneShot event fired: HEARTBEAT
I/TSLocationManager( 2079): ╠═════════════════════════════════════════════
I/TSLocationManager( 2079): [c.t.l.s.TSScheduleManager oneShot]
I/TSLocationManager( 2079):   ⏰ Scheduled OneShot: HEARTBEAT in 60000ms (jobID: -1307475748)
D/TSLocationManager( 2079): [c.t.l.service.HeartbeatService onHeartbeat] ❤️
I/ViewRootImpl@5c296c9[MainActivity]( 2079): MSG_WINDOW_FOCUS_CHANGED 0 1
I/ViewRootImpl@5c296c9[MainActivity]( 2079): handleAppVisibility mAppVisible=true visible=false
I/ViewRootImpl@5c296c9[MainActivity]( 2079): stopped(true) old=false
I/SurfaceView@754a70f( 2079): 165784024 wPL, frameNr = 0
I/SurfaceView@754a70f( 2079): aOrMT: uB = true t = android.view.SurfaceControl$Transaction@3d928cd fN = 0 android.view.SurfaceView.access$500:124 android.view.SurfaceView$SurfaceViewPositionUpdateListener.positionLost:1785 android.graphics.RenderNode$CompositePositionUpdateListener.positionLost:326
I/SurfaceView@754a70f( 2079): aOrMT: vR.mWNT, vR = ViewRootImpl@5c296c9[MainActivity]
I/ViewRootImpl@5c296c9[MainActivity]( 2079): mWNT: t = android.view.SurfaceControl$Transaction@3d928cd fN = 0 android.view.SurfaceView.applyOrMergeTransaction:1628 android.view.SurfaceView.access$500:124 android.view.SurfaceView$SurfaceViewPositionUpdateListener.positionLost:1785
I/ViewRootImpl@5c296c9[MainActivity]( 2079): mWNT: merge t to BBQ
D/SessionLifecycleClient( 2079): Data Collection is disabled for all subscribers. Skipping this Event
I/SurfaceView@754a70f( 2079): windowStopped(true) false io.flutter.embedding.android.FlutterSurfaceView{754a70f V.E...... ........ 0,0-1440,2872} of ViewRootImpl@5c296c9[MainActivity]
I/SurfaceView@754a70f( 2079): pST: mTmpTransaction.apply, mTmpTransaction = android.view.SurfaceControl$Transaction@4a6e606
I/SurfaceView@754a70f( 2079): surfaceDestroyed callback.size 1 #1 io.flutter.embedding.android.FlutterSurfaceView{754a70f V.E...... ........ 0,0-1440,2872}
I/SurfaceView@754a70f( 2079): updateSurface: mVisible = false mSurface.isValid() = true
I/SurfaceView@754a70f( 2079): remove() io.flutter.embedding.android.FlutterSurfaceView{754a70f V.E...... ........ 0,0-1440,2872} Surface(name=SurfaceView - com.evacheckin.app.uat/com.evacheckin.app.MainActivity@754a70f@3)/@0xbe55131
I/TSLocationManager( 2079): [c.t.l.s.TSScheduleManager oneShot]
I/TSLocationManager( 2079):   ⏰ Scheduled OneShot: TERMINATE_EVENT in 10000ms (jobID: -1708771588)
D/SurfaceView@754a70f( 2079): updateSurface: surface is not valid
I/SurfaceView@754a70f( 2079): onWindowVisibilityChanged(8) false io.flutter.embedding.android.FlutterSurfaceView{754a70f G.E...... ......I. 0,0-1440,2872} of ViewRootImpl@5c296c9[MainActivity]
D/SurfaceView@754a70f( 2079): updateSurface: surface is not valid
D/OpenGLRenderer( 2079): setSurface called with nullptr
D/OpenGLRenderer( 2079): setSurface() destroyed EGLSurface
D/OpenGLRenderer( 2079): destroyEglSurface
I/ViewRootImpl@5c296c9[MainActivity]( 2079): Relayout returned: old=(0,0,1440,3040) new=(0,0,1440,3040) req=(1440,3040)8 dur=3 res=0x5 s={false 0} ch=false fn=-1
D/SurfaceView@754a70f( 2079): updateSurface: surface is not valid
D/InputTransport( 2079): Input channel destroyed: 'ClientS', fd=210
D/TSLocationManager( 2079): [c.t.l.l.LifecycleManager onPause] ☯️  onPause
D/TSBackgroundFetch( 2079): ☯️  onPause
D/TSLocationManager( 2079): [c.t.l.l.LifecycleManager onStop] ☯️  onStop
D/TSBackgroundFetch( 2079): ☯️  onStop
I/FA      ( 2079): Application backgrounded at: timestamp_millis: 1738020353185
D/TSLocationManager( 2079): [c.t.l.service.AbstractService a]
D/TSLocationManager( 2079):   🎾  start [GeofencingService  startId: 1, eventCount: 1]
W/TSLocationManager( 2079): [c.t.l.g.TSGeofence$Builder build]
W/TSLocationManager( 2079):   ⚠️  Geofence radius: 96.0:  recommended geofence radius is >= 150.0meters
D/TSLocationManager( 2079): [c.t.l.g.TSGeofenceManager e] ℹ️  Persist monitored polygons: {}
V/TSLocationManager( 2079): [JNI geofencing] clearPolygon de01e686-d7b8-4794-8c92-06c268a2b844
I/TSLocationManager( 2079): [c.t.l.s.GeofencingService a]
I/TSLocationManager( 2079): ╔═════════════════════════════════════════════
I/TSLocationManager( 2079): ║ Geofencing Event: EXIT
I/TSLocationManager( 2079): ╠═════════════════════════════════════════════
I/TSLocationManager( 2079): ╟─ EXIT containing geofence of Polygon: de01e686-d7b8-4794-8c92-06c268a2b844
I/TSLocationManager( 2079): ╚═════════════════════════════════════════════
D/TSLocationManager( 2079): [c.t.l.service.AbstractService a]
D/TSLocationManager( 2079):   ⚙️︎   FINISH [GeofencingService startId: 1, eventCount: 0, sticky: false]
D/TSLocationManager( 2079): [c.t.l.service.AbstractService f]
D/TSLocationManager( 2079):   ⚙️︎  GeofencingService.stopSelfResult(1): true
D/TSLocationManager( 2079): [c.t.l.service.AbstractService onDestroy]
D/TSLocationManager( 2079):   🔴  GeofencingService stopped
I/TSLocationManager( 2079): [c.t.l.scheduler.ScheduleEvent a]
I/TSLocationManager( 2079): ╔═════════════════════════════════════════════
I/TSLocationManager( 2079): ║ ⏰ OneShot event fired: TERMINATE_EVENT
I/TSLocationManager( 2079): ╠═════════════════════════════════════════════
D/TSLocationManager( 2079): [c.t.l.event.TerminateEvent$a onChange]
D/TSLocationManager( 2079):   ℹ️  TERMINATE_EVENT ignored (MainActivity is still active).
-------------------------------------------------------------------------------------------------
@ArthurKim19971001 ArthurKim19971001 changed the title [Help Wanted]: Polygone geofencing event:EXIT is not trigger even register the events [Help Wanted]: Polygone geofencing event:EXIT is not trigger. Jan 27, 2025
@ArthurKim19971001 ArthurKim19971001 changed the title [Help Wanted]: Polygone geofencing event:EXIT is not trigger. [Help Wanted]: Polygone geofencing event:EXIT is not trigger in Android Jan 27, 2025
@christocracy
Copy link
Member

Show me the exact polygon vertices you’re using.

@ArthurKim19971001
Copy link
Author

Show me the exact polygon vertices you’re using.

Image

@christocracy
Copy link
Member

As text, not a screenshot. I need to copy/paste them

@ArthurKim19971001
Copy link
Author

ArthurKim19971001 commented Jan 28, 2025

As text, not a screenshot. I need to copy/paste them

[
  [-36.72635, 174.715286],
  [-36.726152, 174.716547], 
  [-36.726782, 174.716048], 
  [-36.727422, 174.716467], 
  [-36.727655, 174.715737], 
  [-36.72635, 174.715286]
]

@christocracy
Copy link
Member

You cannot have an EXIT event from a polygon until you first cause an ENTER event to fire.

@ArthurKim19971001
Copy link
Author

You cannot have an EXIT event from a polygon until you first cause an ENTER event to fire.

It already triggered ENTER event but EXIT event is still not triggered. Please check the logger blow.. Thank you

D/TSLocationManager( 4404): [c.t.l.service.AbstractService a]
D/TSLocationManager( 4404): 🎾 start [GeofencingService startId: 1, eventCount: 1]
W/TSLocationManager( 4404): [c.t.l.g.TSGeofence$Builder build]
W/TSLocationManager( 4404): ⚠️ Geofence radius: 96.0: recommended geofence radius is >= 150.0meters
D/TSLocationManager( 4404): [c.t.l.g.TSGeofenceManager e] ℹ️ Persist monitored polygons: {de01e686-d7b8-4794-8c92-06c268a2b844=false}
V/TSLocationManager( 4404): [JNI geofencing] loadPolygon de01e686-d7b8-4794-8c92-06c268a2b844
I/TSLocationManager( 4404): [c.t.l.s.GeofencingService a]
I/TSLocationManager( 4404): ╔═════════════════════════════════════════════
I/TSLocationManager( 4404): ║ Geofencing Event: ENTER
I/TSLocationManager( 4404): ╠═════════════════════════════════════════════
I/TSLocationManager( 4404): ╟─ ENTER containing geofence of Polygon: de01e686-d7b8-4794-8c92-06c268a2b844
I/TSLocationManager( 4404): ╚═════════════════════════════════════════════
D/TSLocationManager( 4404): [c.t.l.service.AbstractService a]
D/TSLocationManager( 4404): ⚙️︎ FINISH [GeofencingService startId: 1, eventCount: 0, sticky: false]
D/TSLocationManager( 4404): [c.t.l.service.AbstractService a]
D/TSLocationManager( 4404): 🎾 start [PolygonGeofencingService startId: 1, eventCount: 1]
D/TSLocationManager( 4404): [c.t.l.s.PolygonGeofencingService e]
D/TSLocationManager( 4404): 🎾 startUpdatingLocation
D/TSLocationManager( 4404): [c.t.l.service.AbstractService a]
D/TSLocationManager( 4404): ⚙️︎ FINISH [PolygonGeofencingService startId: 1, eventCount: 0, sticky: true]
D/TSLocationManager( 4404): [c.t.l.service.AbstractService f]
D/TSLocationManager( 4404): ⚙️︎ GeofencingService.stopSelfResult(1): true
D/TSLocationManager( 4404): [c.t.l.service.AbstractService onDestroy]
D/TSLocationManager( 4404): 🔴 GeofencingService stopped
D/TSLocationManager( 4404): [c.t.l.service.AbstractService a]
D/TSLocationManager( 4404): 🎾 start [PolygonGeofencingService startId: 2, eventCount: 1]
D/TSLocationManager( 4404): [c.t.l.s.PolygonGeofencingService c]
D/TSLocationManager( 4404): ╔═════════════════════════════════════════════
D/TSLocationManager( 4404): ║ isInPolygon: 📍 -36.726687224429156, 174.71563920378685, acy: 0.01m, spd: -1
D/TSLocationManager( 4404): ╠═════════════════════════════════════════════
D/TSLocationManager( 4404): [c.t.l.geofence.TSGeofence isLocationInPolygon] --> de01e686-d7b8-4794-8c92-06c268a2b844: 100.0%
D/TSLocationManager( 4404): [c.t.l.service.AbstractService a]
D/TSLocationManager( 4404): ⚙️︎ FINISH [PolygonGeofencingService startId: 2, eventCount: 0, sticky: true]
D/TSLocationManager( 4404): [c.t.l.service.AbstractService a]
D/TSLocationManager( 4404): 🎾 start [PolygonGeofencingService startId: 3, eventCount: 1]
D/TSLocationManager( 4404): [c.t.l.s.PolygonGeofencingService c]
D/TSLocationManager( 4404): ╔═════════════════════════════════════════════
D/TSLocationManager( 4404): ║ isInPolygon: 📍 -36.726687224429156, 174.71563920378685, acy: 0.01m, spd: -1
D/TSLocationManager( 4404): ╠═════════════════════════════════════════════
D/TSLocationManager( 4404): [c.t.l.geofence.TSGeofence isLocationInPolygon] --> de01e686-d7b8-4794-8c92-06c268a2b844: 100.0%
D/TSLocationManager( 4404): [c.t.l.service.AbstractService a]
D/TSLocationManager( 4404): ⚙️︎ FINISH [PolygonGeofencingService startId: 3, eventCount: 0, sticky: true]
D/TSLocationManager( 4404): [c.t.l.service.AbstractService a]
D/TSLocationManager( 4404): 🎾 start [PolygonGeofencingService startId: 4, eventCount: 1]
D/TSLocationManager( 4404): [c.t.l.s.PolygonGeofencingService c]
D/TSLocationManager( 4404): ╔═════════════════════════════════════════════
D/TSLocationManager( 4404): ║ isInPolygon: 📍 -36.726687224429156, 174.71563920378685, acy: 0.01m, spd: -1
D/TSLocationManager( 4404): ╠═════════════════════════════════════════════
D/TSLocationManager( 4404): [c.t.l.geofence.TSGeofence isLocationInPolygon] --> de01e686-d7b8-4794-8c92-06c268a2b844: 100.0%
D/TSLocationManager( 4404): [c.t.l.g.TSGeofenceManager e] ℹ️ Persist monitored polygons: {de01e686-d7b8-4794-8c92-06c268a2b844=true}
W/TSLocationManager( 4404): [c.t.l.g.TSGeofence$Builder build]
W/TSLocationManager( 4404): ⚠️ Geofence radius: 96.0: recommended geofence radius is >= 150.0meters
I/TSLocationManager( 4404): [c.t.l.s.PolygonGeofencingService handleGeofencingEvent]
I/TSLocationManager( 4404): ╔═════════════════════════════════════════════
I/TSLocationManager( 4404): ║ Geofencing Event: ENTER
I/TSLocationManager( 4404): ╠═════════════════════════════════════════════
I/TSLocationManager( 4404): ╟─ de01e686-d7b8-4794-8c92-06c268a2b844
I/TSLocationManager( 4404): ╚═════════════════════════════════════════════
I/TSLocationManager( 4404): [c.t.l.logger.TSLog log]
I/TSLocationManager( 4404): ℹ️ [GeofenceService enqueue] [GeolocationEvent name: location, data: [Location {odometer: 0, activity: {confidence: 100, type: still}, mock: true, extras: {}, battery: {level: 1, is_charging: true}, uuid: 393d64bc-553c-448b-a16e-7967ebfa102c, age: 2100, coords: {altitude: 0, heading: -1, latitude: -36.726687224429156, accuracy: 0.01, heading_accuracy: 0.1, altitude_accuracy: 0.1, speed_accuracy: 0.01, speed: -1, age: 2110, longitude: 174.71563920378685, ellipsoidal_altitude: 0}, is_moving: false, timestamp: 2025-01-28T21:24:23.929Z}], id: 3418e9be-17f2-4c35-9d4c-e1ec083c0285, isHeadless: false]
I/TSLocationManager( 4404): [c.t.l.d.s.SQLiteLocationDAO persist]
I/TSLocationManager( 4404): ✅ INSERT: cfdd902a-d32d-4e77-a17e-2a3efa2cc59e
I/TSLocationManager( 4404): [c.t.l.http.HttpService flush]
I/TSLocationManager( 4404): ╔═════════════════════════════════════════════
I/TSLocationManager( 4404): ║ HTTP Service (count: 1)
I/TSLocationManager( 4404): ╠═════════════════════════════════════════════
D/TSLocationManager( 4404): [c.t.l.s.PolygonGeofencingService f]
D/TSLocationManager( 4404): 🔴 stopUpdatingLocation
D/TSLocationManager( 4404): [c.t.l.service.AbstractService a]
D/TSLocationManager( 4404): ⚙️︎ FINISH [PolygonGeofencingService startId: 4, eventCount: 0, sticky: false]
I/TSLocationManager( 4404): [c.t.l.logger.TSLog log]
I/TSLocationManager( 4404): ℹ️ [GeofenceService enqueue] [GeolocationEvent name: geofence, data: [GeofenceEvent identifier: de01e686-d7b8-4794-8c92-06c268a2b844, action: ENTER, timestamp: 2025-01-28T21:24:26.051Z], id: 15b9d0fd-712b-4fb5-9943-ad2ebaf73cad, isHeadless: false]
I/TSLocationManager( 4404): [c.t.l.u.BackgroundTaskManager$Task start] ⏳ startBackgroundTask: 30
I/TSLocationManager( 4404): [c.t.l.logger.TSLog log]
I/TSLocationManager( 4404): ℹ️ [GeofenceService _runBackgroundTask] [GeolocationEvent name: location, data: [Location {odometer: 0, activity: {confidence: 100, type: still}, mock: true, extras: {}, battery: {level: 1, is_charging: true}, uuid: 393d64bc-553c-448b-a16e-7967ebfa102c, age: 2100, coords: {altitude: 0, heading: -1, latitude: -36.726687224429156, accuracy: 0.01, heading_accuracy: 0.1, altitude_accuracy: 0.1, speed_accuracy: 0.01, speed: -1, age: 2110, longitude: 174.71563920378685, ellipsoidal_altitude: 0}, is_moving: false, timestamp: 2025-01-28T21:24:23.929Z}], id: 3418e9be-17f2-4c35-9d4c-e1ec083c0285, isHeadless: false]
I/TSLocationManager( 4404): [c.t.l.u.BackgroundTaskManager$Task start] ⏳ startBackgroundTask: 31
D/TSLocationManager( 4404): [c.t.l.d.s.SQLiteLocationDAO first]
D/TSLocationManager( 4404): ✅ Locked 1 records
I/TSLocationManager( 4404): [c.t.l.http.HttpService a]
I/TSLocationManager( 4404): 🔵 HTTP POST: cfdd902a-d32d-4e77-a17e-2a3efa2cc59e
I/TSLocationManager( 4404): [c.t.l.u.BackgroundTaskManager$Task stop] ⏳ stopBackgroundTask: 30
I/WM-WorkerWrapper( 4404): Worker result SUCCESS for Work [ id=8b2e3a12-8f4f-4f64-aaa8-d2c99fdcea00, tags={ com.transistorsoft.locationmanager.util.BackgroundTaskWorker } ]
D/TSLocationManager( 4404): [c.t.l.service.AbstractService f]
D/TSLocationManager( 4404): ⚙️︎ PolygonGeofencingService.stopSelfResult(4): true
D/TSLocationManager( 4404): [c.t.l.service.AbstractService onDestroy]
D/TSLocationManager( 4404): 🔴 PolygonGeofencingService stopped
I/TSLocationManager( 4404): [c.t.l.u.BackgroundTaskManager$Task start] ⏳ startBackgroundTask: 32
I/TSLocationManager( 4404): [c.t.l.logger.TSLog log]
I/TSLocationManager( 4404): ℹ️ [GeofenceService _runBackgroundTask] [GeolocationEvent name: geofence, data: [GeofenceEvent identifier: de01e686-d7b8-4794-8c92-06c268a2b844, action: ENTER, timestamp: 2025-01-28T21:24:26.051Z], id: 15b9d0fd-712b-4fb5-9943-ad2ebaf73cad, isHeadless: false]
I/flutter ( 4404): Forwarding to _handleLocation...
I/TSLocationManager( 4404): [c.t.l.http.HttpService$f onResponse]
I/TSLocationManager( 4404): 🔵 Response: 200
D/TSLocationManager( 4404): [c.t.l.d.s.SQLiteLocationDAO destroy]
D/TSLocationManager( 4404): ✅ DESTROY: cfdd902a-d32d-4e77-a17e-2a3efa2cc59e
I/TSLocationManager( 4404): [c.t.l.u.BackgroundTaskManager$Task stop] ⏳ stopBackgroundTask: 31
I/TSLocationManager( 4404): [c.t.l.logger.TSLog log]
I/TSLocationManager( 4404): ℹ️ [GeofenceService enqueue] [GeolocationEvent name: http, data: {location: {action: ENTER, identifier: de01e686-d7b8-4794-8c92-06c268a2b844, httpVersion: 1, event: geofence, timestamp: 2025-01-28T21:24:23.929Z, accuracy: 0.01, activityConfidence: 100, device: samsung SM-G977N, type: 1, siteId: 14617, terminalId: null}}, id: 2076a7cc-a5d1-4c91-9249-549683f00005, isHeadless: false]
I/WM-WorkerWrapper( 4404): Worker result SUCCESS for Work [ id=22896fe4-cb73-43f5-a0a8-1c71016a1d1f, tags={ com.transistorsoft.locationmanager.util.BackgroundTaskWorker } ]
I/flutter ( 4404): already checked in
I/flutter ( 4404): Entry ignored - already checked in.
I/TSLocationManager( 4404): [c.t.l.u.BackgroundTaskManager$Task stop] ⏳ stopBackgroundTask: 32
I/WM-WorkerWrapper( 4404): Worker result SUCCESS for Work [ id=8a386ae2-f54b-4d6a-b092-28bf72fc0629, tags={ com.transistorsoft.locationmanager.util.BackgroundTaskWorker } ]
I/TSLocationManager( 4404): [c.t.l.u.BackgroundTaskManager$Task start] ⏳ startBackgroundTask: 33
I/TSLocationManager( 4404): [c.t.l.logger.TSLog log]
I/TSLocationManager( 4404): ℹ️ [GeofenceService _runBackgroundTask] [GeolocationEvent name: http, data: {location: {action: ENTER, identifier: de01e686-d7b8-4794-8c92-06c268a2b844, httpVersion: 1, event: geofence, timestamp: 2025-01-28T21:24:23.929Z, accuracy: 0.01, activityConfidence: 100, device: samsung SM-G977N, type: 1, siteId: 14617, terminalId: null}}, id: 2076a7cc-a5d1-4c91-9249-549683f00005, isHeadless: false]
I/flutter ( 4404): already checked in
I/flutter ( 4404): Entry ignored - already checked in.
I/TSLocationManager( 4404): [c.t.l.u.BackgroundTaskManager$Task stop] ⏳ stopBackgroundTask: 33
I/WM-WorkerWrapper( 4404): Worker result SUCCESS for Work [ id=fb153b95-8818-448d-8a0f-13077694f131, tags={ com.transistorsoft.locationmanager.util.BackgroundTaskWorker } ]
D/TSLocationManager( 4404): [c.t.l.service.AbstractService a]
D/TSLocationManager( 4404): 🎾 start [GeofencingService startId: 1, eventCount: 1]
W/TSLocationManager( 4404): [c.t.l.g.TSGeofence$Builder build]
W/TSLocationManager( 4404): ⚠️ Geofence radius: 96.0: recommended geofence radius is >= 150.0meters
D/TSLocationManager( 4404): [c.t.l.g.TSGeofenceManager e] ℹ️ Persist monitored polygons: {}
V/TSLocationManager( 4404): [JNI geofencing] clearPolygon de01e686-d7b8-4794-8c92-06c268a2b844
I/TSLocationManager( 4404): [c.t.l.s.GeofencingService a]
I/TSLocationManager( 4404): ╔═════════════════════════════════════════════
I/TSLocationManager( 4404): ║ Geofencing Event: EXIT
I/TSLocationManager( 4404): ╠═════════════════════════════════════════════
I/TSLocationManager( 4404): ╟─ EXIT containing geofence of Polygon: de01e686-d7b8-4794-8c92-06c268a2b844
I/TSLocationManager( 4404): ╚═════════════════════════════════════════════
D/TSLocationManager( 4404): [c.t.l.service.AbstractService a]
D/TSLocationManager( 4404): ⚙️︎ FINISH [GeofencingService startId: 1, eventCount: 0, sticky: false]
D/TSLocationManager( 4404): [c.t.l.service.AbstractService f]
D/TSLocationManager( 4404): ⚙️︎ GeofencingService.stopSelfResult(1): true
D/TSLocationManager( 4404): [c.t.l.service.AbstractService onDestroy]
D/TSLocationManager( 4404): 🔴 GeofencingService stopped
I/TSLocationManager( 4404): [c.t.l.scheduler.ScheduleEvent a]
I/TSLocationManager( 4404): ╔═════════════════════════════════════════════
I/TSLocationManager( 4404): ║ ⏰ OneShot event fired: HEARTBEAT
I/TSLocationManager( 4404): ╠═════════════════════════════════════════════
I/TSLocationManager( 4404): [c.t.l.s.TSScheduleManager oneShot]
I/TSLocationManager( 4404): ⏰ Scheduled OneShot: HEARTBEAT in 60000ms (jobID: -1307475748)
D/TSLocationManager( 4404): [c.t.l.service.HeartbeatService onHeartbeat] ❤️

@christocracy
Copy link
Member

Why do you keep calling .addGeofence?

TSLocationManager( 4404): [c.t.l.g.TSGeofence$Builder build]
W/TSLocationManager( 4404): ⚠️ Geofence radius: 96.0:

@ArthurKim19971001
Copy link
Author

I used .addGeofences once to register the geofence boundary in backgroundGeolocation.

@ArthurKim19971001
Copy link
Author

Why do you keep calling .addGeofence?

TSLocationManager( 4404): [c.t.l.g.TSGeofence$Builder build]
W/TSLocationManager( 4404): ⚠️ Geofence radius: 96.0:

I use the same logic to add the circle geofence and polygon geofence, only the problem is occurred in polygon..

@christocracy
Copy link
Member

Avoid recreating an already existing geofence.

@ArthurKim19971001
Copy link
Author

Avoid recreating an already existing geofence.

I do not recreating the existing geofence.. how I know the geofences are recreating from the log?

@christocracy
Copy link
Member

TSLocationManager( 4404): [c.t.l.g.TSGeofence$Builder build]
W/TSLocationManager( 4404): ⚠️ Geofence radius: 96.0:

@ArthurKim19971001
Copy link
Author

TSLocationManager( 4404): [c.t.l.g.TSGeofence$Builder build]
W/TSLocationManager( 4404): ⚠️ Geofence radius: 96.0:

Using geofenceExists to check there is existing geofence or not and then add geofences. But stil the check out is not triggered.

for (var sdkGeofence in sdkGeofences) {
  if (!(await bg.BackgroundGeolocation.geofenceExists(sdkGeofence.identifier))) {
    tempGeofences.add(sdkGeofence);
  }
}
await bg.BackgroundGeolocation.addGeofences(tempGeofences);

@ArthurKim19971001
Copy link
Author

TSLocationManager( 4404): [c.t.l.g.TSGeofence$Builder build]
W/TSLocationManager( 4404): ⚠️ Geofence radius: 96.0:

It seems like 'Persist monitored polygons' is empty and 'clearPolygon' was running in logs when try to exit. Is that correct process? Could this be the reason why the exit event is not triggered?

D/TSLocationManager( 4404): [c.t.l.service.AbstractService a]
D/TSLocationManager( 4404): 🎾 start [GeofencingService startId: 1, eventCount: 1]
W/TSLocationManager( 4404): [c.t.l.g.TSGeofence$Builder build]
W/TSLocationManager( 4404): ⚠️ Geofence radius: 96.0: recommended geofence radius is >= 150.0meters
D/TSLocationManager( 4404): [c.t.l.g.TSGeofenceManager e] ℹ️ Persist monitored polygons: {}
V/TSLocationManager( 4404): [JNI geofencing] clearPolygon de01e686-d7b8-4794-8c92-06c268a2b844
I/TSLocationManager( 4404): [c.t.l.s.GeofencingService a]
I/TSLocationManager( 4404): ╔═════════════════════════════════════════════
I/TSLocationManager( 4404): ║ Geofencing Event: EXIT
I/TSLocationManager( 4404): ╠═════════════════════════════════════════════
I/TSLocationManager( 4404): ╟─ EXIT containing geofence of Polygon: de01e686-d7b8-4794-8c92-06c268a2b844
I/TSLocationManager( 4404): ╚═════════════════════════════════════════════

@christocracy
Copy link
Member

Is that correct process? Could this be the reason why the exit event is not triggered?

Yes.

The way this plugin works is to wrap a polygon within a native circular geofence (ie: "the containing geofence of polygon"), represented below as green containing circles of the blue-dotted polygons.

Image

When the device enter the green circle (the "containing geofence"), the plugin initiates aggressive location monitoring, using each location to "hit test" upon the polygon:

  • Is location in polygon?
  • Is location in polygon?
  • Is location in polygon?
  • Is location in polygon?
    .
    .
    .

Once the device exits the "containing geofence", the plugin halts its aggressive hit-testing algorithm, represented in the logs as:

TSLocationManager( 4404): ╔═════════════════════════════════════════════
I/TSLocationManager( 4404): ║ Geofencing Event: EXIT
I/TSLocationManager( 4404): ╠═════════════════════════════════════════════
I/TSLocationManager( 4404): ╟─ EXIT containing geofence of Polygon: de01e686-d7b8-4794-8c92-06c268a2b844
I/TSLocationManager( 4404): ╚═════════════════════════════════════════════

This explained in the API docs

@ArthurKim19971001
Copy link
Author

Is that correct process? Could this be the reason why the exit event is not triggered?

Yes.

The way this plugin works is to wrap a polygon within a native circular geofence (ie: "the containing geofence of polygon"), represented below as green containing circles of the blue-dotted polygons.

Image When the device enter the green circle (the "containing geofence"), the plugin initiates aggressive location monitoring, using each location to "hit test" upon the polygon:
  • Is location in polygon?
  • Is location in polygon?
  • Is location in polygon?
  • Is location in polygon?
    .
    .
    .

Once the device exits the "containing geofence", the plugin halts its aggressive hit-testing algorithm, represented in the logs as:

TSLocationManager( 4404): ╔═════════════════════════════════════════════
I/TSLocationManager( 4404): ║ Geofencing Event: EXIT
I/TSLocationManager( 4404): ╠═════════════════════════════════════════════
I/TSLocationManager( 4404): ╟─ EXIT containing geofence of Polygon: de01e686-d7b8-4794-8c92-06c268a2b844
I/TSLocationManager( 4404): ╚═════════════════════════════════════════════

This explained in the API docs

How do I listen this event then? It is not able to triggered even using onLocation in BackgroundGeolocation. Please let me know how do I updated it for polygon.

bg.BackgroundGeolocation.onLocation(
(data) => enqueue(GeolocationEvent(bg.Event.LOCATION, data)),
);

@christocracy
Copy link
Member

That’s not how you listen to geofence events.

Read the api docs event .onGeofence.

Also read the “Geofencing Guide”, linked throughout.

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