Open TNAJanssen opened 2 months ago
You should be registering event-listeners before calling ready or you can miss events.
// Listen to events BEFORE calling .ready
BackgroundGeolocation.onEnabledChange((event) => {
console.log('- onEnabledChange: ', event);
});
BackgroundGeolocation.ready(config);
// NOT AFTER
BackgroundGeolocation.onEnabledChange((event) => {
console.log('- onEnabledChange: ', event);
});
Listening to event-listeners is a completely innocuous action -- it does nothing more than push a callback function onto an Array
. You do not need to wait for anything to add a listener. It's perfectly fine to register listeners even if you don't have a logged-in user.
This issue is stale because it has been open for 30 days with no activity.
@christocracy I have RN 0.72, plugin version 4.14.3 and the same issue. But I did set listeners BEFORE calling .ready() method. It works as expected on Android 14. And there is one more interesting moment: onLocation callback fires as expected.
There is no difference in performance between a debug and release build. To believe so is nothing more than superstition, like believing that walking under a ladder brings bad luck.
the first thing you do when something unusual happens is analyze your logs. See wiki “Debugging” and api docs “.emailLog”. Place a geofence 200 meters away then go outside with a REAL device (not emulator) and walk into it with the plug-in configured for debug: true (so you can hear the debug sound FX). Go outside and walk in/out of your test geofence.
@christocracy Was your previous message addressed to me? If so, I don't understand how walking with the real device can help to catch missing "onEnabled" callback? I see this issue on the dev/prod builds and I test your plugin on real devices only. The issue exists on iPhone XS Max, Android 14 Samsung device and iOS iPhone simulator.
The title of this issue is “onEnabled and onGeofence not triggering on production but does work on development”.
you said you have the “same issue”.
@christocracy I wasn't accurate when was reading issue title. I'm sorry. I have NO the same issue. It's something different.
This issue is stale because it has been open for 30 days with no activity.
Your Environment
react-native -v
): 0.73.6Expected Behavior
OnEnabled and onGeofence are called
Actual Behavior
OnEnabled and onGeofence are not called on iOS with a preview and production build, but the debug notifications are triggered. On a older iPhone it seems to work, but on 2 iPhone 15 Pro Max phones it doesn't work.
Steps to Reproduce
Context
Send a notification when the onEnabledChange is called with enabled true. It works perfectly on Android and on my development build.
Debug logs
Logs
``` 2024-06-27 17:20:10.315 ℹ️-[TSConfig persist] 2024-06-27 17:20:21.934 ℹ️-[TSConfig persist] 2024-06-27 17:20:22.141 ℹ️-[TSConfig persist] 2024-06-27 17:20:23.620 ℹ️-[TSConfig persist] 2024-06-27 17:20:23.683 ℹ️-[TSLocationManager log:message:] [RNBackgroundGeolocation startObserving] 2024-06-27 17:20:23.913 ℹ️-[TSLocationManager log:message:] [RNBackgroundGeolocation stopObserving] 2024-06-27 17:20:23.913 ℹ️-[TSLocationManager log:message:] [RNBackgroundGeolocation startObserving] 2024-06-27 17:20:29.092 🔵-[LocationManager locationManager:didChangeAuthorizationStatus:] 4 2024-06-27 17:20:29.093 🔵-[PolygonGeofencingService locationManager:didChangeAuthorizationStatus:] 4 2024-06-27 17:20:29.093 🔵-[LocationManager locationManager:didChangeAuthorizationStatus:] 4 2024-06-27 17:20:29.094 🔵-[BackgroundTaskManager locationManager:didChangeAuthorizationStatus:] 4 2024-06-27 17:20:29.095 ℹ️-[TSConfig persist] 2024-06-27 17:20:29.096 🔵-[TSLocationManager locationManager:didChangeAuthorizationStatus:] status 4 2024-06-27 17:20:29.102 🔵-[LocationManager locationManager:didChangeAuthorizationStatus:] 4 2024-06-27 17:20:30.849 🔵-[LocationManager locationManager:didChangeAuthorizationStatus:] 3 2024-06-27 17:20:30.858 🔵-[PolygonGeofencingService locationManager:didChangeAuthorizationStatus:] 3 2024-06-27 17:20:30.858 🔵-[LocationManager locationManager:didChangeAuthorizationStatus:] 3 2024-06-27 17:20:30.858 🔵-[BackgroundTaskManager locationManager:didChangeAuthorizationStatus:] 3 2024-06-27 17:20:30.858 ℹ️-[TSConfig persist] 2024-06-27 17:20:30.859 🔵-[TSLocationManager locationManager:didChangeAuthorizationStatus:] status 3 2024-06-27 17:20:30.862 🔵-[LocationManager locationManager:didChangeAuthorizationStatus:] 3 2024-06-27 17:20:34.735 ℹ️-[GeofenceDAO destroyAll]_block_invoke 2024-06-27 17:20:34.735 🔴-[PolygonGeofencingService stop] 2024-06-27 17:20:34.735 ℹ️-[PolygonGeofencingService persistMonitoredPolygons] { } 2024-06-27 17:20:34.735 🔵-[TSLocationManager addGeofences:success:failure:] 2024-06-27 17:20:34.736 ℹ️-[GeofenceDAO doInsert:geofence:] no-event-id-tenant 2024-06-27 17:20:34.736 ℹ️-[GeofenceDAO doInsert:geofence:] 26de35ea-5513-4c2e-b4a5-a7f43a7eecd1-primaryFromAddress 2024-06-27 17:20:34.775 ℹ️-[TSLocationManager doStart:] trackingMode: 1 2024-06-27 17:20:34.775 ℹ️-[TSConfig persist] 2024-06-27 17:20:34.776 🎾-[TSGeofenceManager start] 2024-06-27 17:20:34.776 🎾-[SOMotionDetector startDetection] 2024-06-27 17:20:34.776 🔵-[TSLocationManager setPace:] 0 2024-06-27 17:20:34.778 🎾-[TSLocationManager startUpdatingLocation] Location-services: ON 2024-06-27 17:20:34.778 ℹ️-[TSConfig persist] 2024-06-27 17:20:34.779 🔵-[TSLocationManager changePace:] isMoving: 1 2024-06-27 17:20:34.779 🔵-[TSLocationManager setPace:] 1 2024-06-27 17:20:34.779 🎾-[SOMotionDetector startShakeDetection:] sample-rate: 0.2 | M7 DISABLED 2024-06-27 17:20:34.780 ✅-[LocationDAO unlock]_block_invoke UNLOCKED ALL RECORDS 2024-06-27 17:20:34.791 ℹ️+[LocationAuthorization run:onCancel:] status: 3 2024-06-27 17:20:34.793 🎾-[TSLocationManager startMonitoringBackgroundFetch] BackgroundFetch: ON 2024-06-27 17:20:34.794 🎾-[TSLocationManager startUpdatingLocation] Location-services: ON 2024-06-27 17:20:34.795 ℹ️-[TSLocationManager startMonitoringBackgroundFetch]_block_invoke Configured BackgroundFetch 2024-06-27 17:20:34.811 ℹ️+[LocationAuthorization run:onCancel:] status: 3 2024-06-27 17:20:34.811 ℹ️-[PolygonGeofencingService setLocation:] Already updating location