Description
Hi,
I want to test in debug mode before purchasing licence. I try to implment the provided sample the geofence is not fireing. may i know what is missing. here is the log and sample code.
Sample Code
import React, { useEffect } from 'react';
import { View, Text, StyleSheet, Alert } from 'react-native';
import BackgroundGeolocation from 'react-native-background-geolocation';
const HomeScreen = () => {
useEffect(() => {
// Listen to geofence events
BackgroundGeolocation.onGeofence(geofence => {
console.log("[geofence] ", geofence);
if (geofence.identifier == "DANGER_ZONE") {
if (geofence.action == "ENTER") {
// Entering the danger-zone, we want to aggressively track location.
BackgroundGeolocation.start();
} else if (geofence.action == "EXIT") {
// Exiting the danger-zone, we resume geofences-only tracking.
BackgroundGeolocation.startGeofences();
}
}
})
// Add a geofence.
BackgroundGeolocation.addGeofence({
identifier: "DANGER_ZONE",
radius: 1000,
latitude: 45.51921926,
longitude: -73.61678581,
notifyOnEntry: true,
notifyOnExit: true,
})
// Ready the plugin.
BackgroundGeolocation.ready({
desiredAccuracy: BackgroundGeolocation.DESIRED_ACCURACY_HIGH,
distanceFilter: 10,
autoSync: true
}, state => {
BackgroundGeolocation.startGeofences();
})
// Clean up on unmount
return () => {
};
}, []);
return (
Geofence Tracking Enabled
Enter or exit the defined DANGER_ZONE (1km radius) to trigger events.
);
};
export default HomeScreen;
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
padding: 24,
backgroundColor: '#f2f2f2',
},
title: {
fontSize: 22,
fontWeight: 'bold',
marginBottom: 12,
},
description: {
fontSize: 16,
textAlign: 'center',
color: '#666',
},
});
===================
LOGS
05-02 16:14:47.614 INFO [LoggerFacade$a a]
╔═════════════════════════════════════════════
║ TSLocationManager version: 3.6.6 (441)
╠═════════════════════════════════════════════
╟─ samsung SM-M315F @ 12 (react)
{
"activityRecognitionInterval": 10000,
"allowIdenticalLocations": false,
"authorization": {},
"autoSync": true,
"autoSyncThreshold": 0,
"backgroundPermissionRationale": {
"title": "Allow {applicationName} to access this device's location even when closed or not in use?",
"message": "[CHANGEME] This app collects location data for FEATURE X and FEATURE Y.",
"positiveAction": "Change to "{backgroundPermissionOptionLabel}"",
"negativeAction": ""
},
"batchSync": false,
"configUrl": "",
"crashDetector": {
"enabled": false,
"accelerometerThresholdHigh": 20,
"accelerometerThresholdLow": 4.5,
"gyroscopeThresholdHigh": 20,
"gyroscopeThresholdLow": 4.5
},
"debug": true,
"deferTime": 0,
"desiredAccuracy": -1,
"desiredOdometerAccuracy": 100,
"disableAutoSyncOnCellular": false,
"disableElasticity": false,
"disableLocationAuthorizationAlert": false,
"disableMotionActivityUpdates": false,
"disableProviderChangeRecord": false,
"disableStopDetection": false,
"distanceFilter": 10,
"elasticityMultiplier": 1,
"enableHeadless": false,
"enableTimestampMeta": false,
"extras": {},
"fastestLocationUpdateInterval": -1,
"foregroundService": true,
"geofenceInitialTriggerEntry": true,
"geofenceModeHighAccuracy": false,
"geofenceProximityRadius": 1000,
"geofenceTemplate": "",
"headers": {},
"headlessJobService": "com.transistorsoft.rnbackgroundgeolocation.HeadlessTask",
"heartbeatInterval": -1,
"httpRootProperty": "location",
"httpTimeout": 60000,
"isMoving": false,
"locationAuthorizationRequest": "Always",
"locationTemplate": "",
"locationTimeout": 60,
"locationUpdateInterval": 1000,
"locationsOrderDirection": "ASC",
"logLevel": 5,
"logMaxDays": 3,
"maxBatchSize": -1,
"maxDaysToPersist": 1,
"maxMonitoredGeofences": 97,
"maxRecordsToPersist": -1,
"method": "POST",
"minimumActivityRecognitionConfidence": 75,
"motionTriggerDelay": 0,
"notification": {
"layout": "",
"title": "",
"text": "Location Service activated",
"color": "",
"channelName": "TSLocationManager",
"channelId": "",
"smallIcon": "",
"largeIcon": "",
"priority": -1,
"sticky": false,
"strings": {},
"actions": []
},
"params": {},
"persist": true,
"persistMode": 2,
"schedule": [],
"scheduleUseAlarmManager": false,
"speedJumpFilter": 300,
"startOnBoot": true,
"stationaryRadius": 25,
"stopAfterElapsedMinutes": 0,
"stopOnStationary": false,
"stopOnTerminate": false,
"stopTimeout": 5,
"triggerActivities": "in_vehicle, on_bicycle, on_foot, running, walking",
"url": "",
"useSignificantChangesOnly": false,
"enabled": true,
"schedulerEnabled": false,
"trackingMode": 0,
"odometer": 0,
"isFirstBoot": false,
"didLaunchInBackground": false,
"didDeviceReboot": false
}
05-02 16:14:47.615 DEBUG [TSSQLiteAppender$c run]
ℹ️ Cleared logs older than 72 hours
05-02 16:14:47.653 INFO [LoggerFacade$a a]
╔═════════════════════════════════════════════
║ DEVICE SENSORS
╠═════════════════════════════════════════════
╟─ ✅ ACCELEROMETER: {Sensor name="LSM6DSL Accelerometer", vendor="STM", version=81468, type=1, maxRange=78.4532, resolution=0.0023942017, power=0.15, minDelay=8000}
╟─ ✅ GYROSCOPE: {Sensor name="LSM6DSL Gyroscope", vendor="STM", version=1, type=4, maxRange=17.453032, resolution=6.1086525E-4, power=0.65, minDelay=8000}
╟─ ✅ MAGNETOMETER: {Sensor name="AK09918C Magnetometer", vendor="Asahi Kasei Microdevices", version=1, type=2, maxRange=4900.02, resolution=0.06, power=1.1, minDelay=8000}
╟─ ✅ SIGNIFICANT_MOTION: {Sensor name="Significant Motion", vendor="Samsung Inc.", version=2, type=17, maxRange=1.0, resolution=1.0, power=0.16, minDelay=-1}
╚═════════════════════════════════════════════
05-02 16:14:47.655 INFO [LoggerFacade$a a]
╔═════════════════════════════════════════════
║ BootReceiver: com.gsmarto
╠═════════════════════════════════════════════
╟─ android.intent.action.MY_PACKAGE_REPLACED
05-02 16:14:47.746 DEBUG [LifecycleManager onCreate] ☯️ onCreate
05-02 16:14:47.748 INFO [BackgroundGeolocation ]
✅ Google Play Services: connected (version code:12451000)
05-02 16:14:47.800 DEBUG [LifecycleManager b]
╔═════════════════════════════════════════════
║ ☯️ HeadlessMode? true
╠═════════════════════════════════════════════
05-02 16:14:47.846 DEBUG [HttpService startMonitoringConnectivityChanges]
🎾 Start monitoring connectivity changes
05-02 16:14:48.042 INFO [TSProviderManager startMonitoring]
🎾 Start monitoring location-provider changes
05-02 16:14:48.052 DEBUG [HttpService a]
╔═════════════════════════════════════════════
║ 📶 Connectivity change: connected? true
╠═════════════════════════════════════════════
05-02 16:14:48.109 DEBUG [HttpService a]
╔═════════════════════════════════════════════
║ 📶 Connectivity change: connected? true
╠═════════════════════════════════════════════
05-02 16:14:48.320 DEBUG [TSGeofenceManager d] ℹ️ Persist monitored geofences: []
05-02 16:14:48.322 INFO [TSGeofenceManager start]
🎾 Start monitoring geofences
05-02 16:14:48.344 WARN [TSLocationManagerActivity start]
05-02 16:14:48.366 DEBUG [HttpService startMonitoringConnectivityChanges]
🎾 Start monitoring connectivity changes
05-02 16:14:48.372 DEBUG [DeviceSettings startMonitoringPowerSaveChanges]
🎾 Start monitoring powersave changes
05-02 16:14:48.375 DEBUG [SQLiteLocationDAO prune]
ℹ️ PRUNE -1 days
05-02 16:14:48.394 INFO [HeartbeatService stop]
🔴 Stop heartbeat
05-02 16:14:48.580 DEBUG [TSGeofenceManager$d run] evaluation buffer timer elapsed
05-02 16:14:48.723 INFO [TSLocationManager a]
╔═════════════════════════════════════════════
║ motionchange LocationResult: 1 (1226ms old)
╠═════════════════════════════════════════════
╟─ 📍 Location[fused -13.330229,-55.627243 hAcc=3.0496988 et=+4d5h18m49s347ms alt=42.39481735229492 vel=0.004971117 mock {Bundle[{}]}], time: 1746173687420
05-02 16:14:48.750 INFO [TSLocationManager onSingleLocationResult]
🔵 Acquired motionchange position, isMoving: false
05-02 16:14:48.753 DEBUG [TSLocationManager a] Median accuracy: 3.0496988
05-02 16:14:49.087 DEBUG [TSGeofenceManager$e a] ℹ️ GeofencingClient addGeofences SUCCESS
05-02 16:14:49.102 DEBUG [TSGeofenceManager d] ℹ️ Persist monitored geofences: [DANGER_ZONE]
05-02 16:14:49.114 DEBUG [TSGeofenceManager$e a]
╔═════════════════════════════════════════════
║ TSGeofenceManager monitoring 1/1
╠═════════════════════════════════════════════
╟─ 🎾 DANGER_ZONE
╚═════════════════════════════════════════════
05-02 16:14:49.130 DEBUG [TSGeofenceManager$e a] ℹ️ GeofencingClient addGeofences SUCCESS
05-02 16:14:49.135 DEBUG [TSGeofenceManager d] ℹ️ Persist monitored geofences: [DANGER_ZONE]
05-02 16:14:49.145 DEBUG [TSGeofenceManager$e a]
╔═════════════════════════════════════════════
║ TSGeofenceManager monitoring 1/1
╠═════════════════════════════════════════════
╟─ 🎾 DANGER_ZONE
╚═════════════════════════════════════════════
05-02 16:14:52.664 DEBUG [LifecycleManager onStart] ☯️ onStart
05-02 16:14:52.670 DEBUG [LifecycleManager onResume] ☯️ onResume
05-02 16:15:00.816 DEBUG [TSConfig e] ℹ️ Persist config, dirty: [debug, desiredAccuracy, extras, headers, headlessJobService, logLevel, params, schedule, startOnBoot, stopOnTerminate]
05-02 16:15:00.829 DEBUG [LocationAuthorization withBackgroundPermission]
ℹ️ LocationAuthorization: Permission granted
05-02 16:15:00.834 DEBUG [HttpService startMonitoringConnectivityChanges]
🎾 Start monitoring connectivity changes
05-02 16:15:00.836 DEBUG [DeviceSettings startMonitoringPowerSaveChanges]
🎾 Start monitoring powersave changes
05-02 16:15:00.838 INFO [HeartbeatService stop]
🔴 Stop heartbeat
05-02 16:15:00.856 INFO [TSLocationManager a]
╔═════════════════════════════════════════════
║ motionchange LocationResult: 2 (1328ms old)
╠═════════════════════════════════════════════
╟─ 📍 Location[fused -13.330238,-55.627242 hAcc=4.5971613 et=+4d5h19m1s382ms alt=46.16781997680664 vel=0.6742931 mock {Bundle[{}]}], time: 1746173699480
05-02 16:15:00.860 DEBUG [TSGeofenceManager setLocation] isMoving: false | stateChanged: false | timerExpired: false | elapsed: 12060 | d: 0.93976593
05-02 16:15:00.861 INFO [TSLocationManager onSingleLocationResult]
🔵 Acquired motionchange position, isMoving: false
05-02 16:15:00.862 DEBUG [TSLocationManager a] Median accuracy: 3.82343
05-02 16:15:00.894 INFO [GeofenceDAO destroy]
✅ DANGER_ZONE
05-02 16:15:00.898 INFO [GeofenceDAO create]
✅ DANGER_ZONE
05-02 16:15:01.009 DEBUG [TSGeofenceManager b] ℹ️ GeofencingClient removeGeofences SUCCESS
05-02 16:15:01.010 DEBUG [TSGeofenceManager d] ℹ️ Persist monitored geofences: []
05-02 16:15:01.012 DEBUG [TSGeofenceManager b] ℹ️ GeofencingClient removeGeofences SUCCESS
05-02 16:15:01.013 DEBUG [TSGeofenceManager d] ℹ️ Persist monitored geofences: []
05-02 16:15:01.014 INFO [GeofenceDAO destroyAll] ✅
05-02 16:15:01.138 INFO [TSScheduleManager oneShot]
⏰ Scheduled OneShot: TERMINATE_EVENT in 10000ms (jobID: -1708771588)
05-02 16:15:01.185 DEBUG [TSLocationManagerActivity a] locationsettings
05-02 16:15:01.269 DEBUG [TSGeofenceManager$d run] evaluation buffer timer elapsed
05-02 16:15:01.282 DEBUG [TSGeofenceManager$e run]
╔═════════════════════════════════════════════
║ TSGeofenceManager monitoring 0/0
╠═════════════════════════════════════════════
╚═════════════════════════════════════════════
05-02 16:15:01.305 DEBUG [TSLocationManagerActivity onDestroy] locationsettings
05-02 16:15:11.219 INFO [ScheduleEvent a]
╔═════════════════════════════════════════════
║ ⏰ OneShot event fired: TERMINATE_EVENT
╠═════════════════════════════════════════════
05-02 16:15:11.221 DEBUG [TerminateEvent$a onChange]
ℹ️ TERMINATE_EVENT ignored (MainActivity is still active).
05-02 16:16:37.722 DEBUG [HttpService a]
╔═════════════════════════════════════════════
║ 📶 Connectivity change: connected? true
╠═════════════════════════════════════════════
05-02 16:19:19.327 WARN [RNBackgroundGeolocationModule ready]
05-02 16:19:19.329 INFO [GeofenceDAO create]
✅ DANGER_ZONE
05-02 16:19:19.330 DEBUG [TSConfig e] ℹ️ Persist config, dirty: [url]
05-02 16:19:19.346 INFO [HttpService flush]
╔═════════════════════════════════════════════
║ HTTP Service (count: 0)
╠═════════════════════════════════════════════
05-02 16:19:19.360 DEBUG [LocationAuthorization withBackgroundPermission]
ℹ️ LocationAuthorization: Permission granted
05-02 16:19:19.363 DEBUG [HttpService startMonitoringConnectivityChanges]
🎾 Start monitoring connectivity changes
05-02 16:19:19.365 DEBUG [DeviceSettings startMonitoringPowerSaveChanges]
🎾 Start monitoring powersave changes
05-02 16:19:19.368 INFO [HeartbeatService stop]
🔴 Stop heartbeat
05-02 16:19:19.401 INFO [TSLocationManager a]
╔═════════════════════════════════════════════
║ motionchange LocationResult: 3 (508ms old)
╠═════════════════════════════════════════════
╟─ 📍 Location[fused -13.330221,-55.627247 hAcc=5.58065 et=+4d5h23m20s746ms alt=42.07469940185547 vel=0.5272986 mock {Bundle[{}]}], time: 1746173958764
05-02 16:19:19.410 DEBUG [TSGeofenceManager setLocation] isMoving: false | stateChanged: false | timerExpired: true | elapsed: 259284 | d: 1.0603497
05-02 16:19:19.412 INFO [TSLocationManager onSingleLocationResult]
🔵 Acquired motionchange position, isMoving: false
05-02 16:19:19.414 DEBUG [TSLocationManager a] Median accuracy: 4.5971613
05-02 16:19:19.582 INFO [TSScheduleManager oneShot]
⏰ Scheduled OneShot: TERMINATE_EVENT in 10000ms (jobID: -1708771588)
05-02 16:19:19.595 DEBUG [TSGeofenceManager$d run] evaluation buffer timer elapsed
05-02 16:19:19.610 DEBUG [TSLocationManagerActivity a] locationsettings
05-02 16:19:19.672 DEBUG [TSGeofenceManager$e a] ℹ️ GeofencingClient addGeofences SUCCESS
05-02 16:19:19.673 DEBUG [TSGeofenceManager d] ℹ️ Persist monitored geofences: [DANGER_ZONE]
05-02 16:19:19.673 DEBUG [TSGeofenceManager$e a]
╔═════════════════════════════════════════════
║ TSGeofenceManager monitoring 1/1
╠═════════════════════════════════════════════
╟─ 🎾 DANGER_ZONE
╚═════════════════════════════════════════════
05-02 16:19:19.703 DEBUG [TSLocationManagerActivity onDestroy] locationsettings
05-02 16:19:31.255 INFO [TSScheduleManager oneShot]
⏰ Oneshot TERMINATE_EVENT is already pending
05-02 16:19:31.954 DEBUG [LifecycleManager onPause] ☯️ onPause
05-02 16:19:31.969 DEBUG [LifecycleManager onStop] ☯️ onStop
05-02 16:19:37.165 INFO [ScheduleEvent a]
╔═════════════════════════════════════════════
║ ⏰ OneShot event fired: TERMINATE_EVENT
╠═════════════════════════════════════════════
05-02 16:19:37.170 DEBUG [TerminateEvent$a onChange]
ℹ️ TERMINATE_EVENT ignored (MainActivity is still active).
05-02 16:19:44.372 DEBUG [LifecycleManager onStart] ☯️ onStart
05-02 16:19:44.397 DEBUG [LifecycleManager onResume] ☯️ onResume
05-02 16:19:44.400 INFO [HttpService flush]
╔═════════════════════════════════════════════
║ HTTP Service (count: 0)
╠═════════════════════════════════════════════
05-02 16:20:23.132 WARN [RNBackgroundGeolocationModule ready]
05-02 16:20:23.134 INFO [GeofenceDAO destroy]
✅ DANGER_ZONE
05-02 16:20:23.136 INFO [GeofenceDAO create]
✅ DANGER_ZONE
05-02 16:20:23.165 DEBUG [LocationAuthorization withBackgroundPermission]
ℹ️ LocationAuthorization: Permission granted
05-02 16:20:23.169 DEBUG [HttpService startMonitoringConnectivityChanges]
🎾 Start monitoring connectivity changes
05-02 16:20:23.170 DEBUG [DeviceSettings startMonitoringPowerSaveChanges]
🎾 Start monitoring powersave changes
05-02 16:20:23.171 INFO [HeartbeatService stop]
🔴 Stop heartbeat
05-02 16:20:23.216 INFO [TSLocationManager a]
╔═════════════════════════════════════════════
║ motionchange LocationResult: 4 (1076ms old)
╠═════════════════════════════════════════════