transistorsoft / react-native-background-geolocation

Sophisticated, battery-conscious background-geolocation with motion-detection
http://shop.transistorsoft.com/pages/react-native-background-geolocation
MIT License
2.63k stars 426 forks source link

Not tracking continusolonce get stopped #2150

Open Naveenkumar-1411 opened 1 day ago

Naveenkumar-1411 commented 1 day ago

Plugin version:react-native-background-geolocation": "^4.16.5" Platform: Android OS version:14 Device manufacturer / model: Iqoo Z7 React Native version (react-native -v):"0.74.1" Plugin config "plugins": [ [ "expo-location", { "locationAlwaysAndWhenInUsePermission": "Allow $(PRODUCT_NAME) to use your location." } ], [ "react-native-background-geolocation", { "license": "My license" } ], [ "expo-gradle-ext-vars", { "googlePlayServicesLocationVersion": "21.1.0", "appCompatVersion": "1.4.2" } ], "react-native-background-fetch" ],

Expected Behavior

Needs to track the the location once moved from the stationary state

Actual Behavior

once i have stopped in one place for more than stopouttime after that not getting tracked

code

const startLocationTracking = () => { BackgroundGeolocation.ready({ reset: true, desiredAccuracy: BackgroundGeolocation.DESIRED_ACCURACY_HIGH, distanceFilter: 10, // Lower to track movement sooner stationaryRadius: 10, debug: true, activityRecognitionInterval: 1000, // More frequent motion detection stopTimeout: 60, // Quicker detection of motion stop disableMotionActivityUpdates: false, disableElasticity: true, // More aggressive updates startOnBoot: true, heartbeatInterval: 60, enableHeadless: true, stopOnTerminate: false, desiredOdometerAccuracy: 10, allowIdenticalLocations: false, fastestLocationUpdateInterval:true, autoSync: true, autoSyncThreshold: 0, batchSync: true, maxBatchSize: 10, maxDaysToPersist: 2, foregroundService: true, notification: { title: "StarGcc", text: "Stay in app the while working hours", priority: BackgroundGeolocation.NOTIFICATION_PRIORITY_HIGH, }, url: ${BASE_URL}/location/track, headers: { Authorization: Bearer ${loginUser.auth_key}, }, params: { device_uuid: Constants.platform.android ? Application.getAndroidId() : Application.installationId, employee_id: loginUser.profile.id, },extras: { device_uuid: Constants.platform.android ? Application.getAndroidId() : Application.installationId, employee_id: loginUser.profile.id, } }) .then((state) => { if (!state.enabled) { BackgroundGeolocation.start(); BackgroundGeolocation.changePace(true); //console.log("BackgroundGeolocation started successfully"); Alert.alert(" started successfully"); } }) .catch((error) => { console.error("BackgroundGeolocation error: ", error); });
BackgroundFetch.configure( { minimumFetchInterval: 5, stopOnTerminate: false, startOnBoot: true }, async (taskId) => { try { const location = await BackgroundGeolocation.getCurrentPosition({ persist: false,extras: { device_uuid: Constants.platform.android ? Application.getAndroidId() : Application.installationId, employee_id: loginUser.profile.id, } }); console.log("Fetched Location:", location); BackgroundGeolocation.sync().then((syncedLocations) => { console.log("Synced locations: ", syncedLocations);

        });

      } catch (error) {
        console.error("Error fetching location:", error);
        BackgroundFetch.finish(taskId);
      }finally{
        BackgroundFetch.finish(taskId);
      }
    },
    (error) => {
      console.error("Failed to start BackgroundFetch:", error);
    }
  );

};
masucode commented 1 day ago

are there any improvement?

Naveenkumar-1411 commented 1 day ago

are there any improvement?

No whether,you have any idea

masucode commented 1 day ago

are there any improvement?

No whether,you have any idea

actually we workin on it right now but there is no good news :(

christocracy commented 1 day ago

Please learn to syntax highlight “fenced code blocks”

https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/creating-and-highlighting-code-blocks#fenced-code-blocks

masucode commented 1 day ago

Logcat error:

E  FATAL EXCEPTION: pool-9-thread-1
                                                                                                    Process: com.masu.washout, PID: 30076
                                                                                                    java.lang.IncompatibleClassChangeError: Found interface com.google.android.gms.location.FusedLocationProviderClient, but class was expected (declaration of 'com.google.android.gms.location.FusedLocationProviderClient' appears in /data/app/~~GVvI3lWnETLI_SIUzY95xw==/com.masu.washout-jnjK6gMTXdb3gAGq4kyBUA==/base.apk!classes6.dex)
                                                                                                        at com.transistorsoft.xms.g.location.FusedLocationProviderClient.removeLocationUpdates(Unknown Source:50)
                                                                                                        at com.transistorsoft.locationmanager.location.TSLocationManager.d(Unknown Source:40)
                                                                                                        at com.transistorsoft.locationmanager.location.TSLocationManager.stopUpdatingLocation(Unknown Source:0)
                                                                                                        at com.transistorsoft.locationmanager.location.TSLocationManager.stop(Unknown Source:0)
                                                                                                        at com.transistorsoft.locationmanager.service.TrackingService.stop(Unknown Source:83)
                                                                                                        at com.transistorsoft.locationmanager.adapter.BackgroundGeolocation.c(Unknown Source:2)
                                                                                                        at com.transistorsoft.locationmanager.adapter.BackgroundGeolocation.$r8$lambda$oSDeWXxQl1jmikdjYQwff60damw(Unknown Source:0)
                                                                                                        at com.transistorsoft.locationmanager.adapter.BackgroundGeolocation$$ExternalSyntheticLambda1.run(Unknown Source:4)
                                                                                                        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
                                                                                                        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
                                                                                                        at java.lang.Thread.run(Thread.java:1012)
2024-09-21 16:33:30.903 30076-30173 TSLocationManager       com.masu.washout                     E  [c.t.l.a.BackgroundGeolocation$w0 uncaughtException] 
                                                                                                      ‼️  Uncaught Exception: Found interface com.google.android.gms.location.FusedLocationProviderClient, but class was expected (declaration of 'com.google.android.gms.location.FusedLocationProviderClient' appears in /data/app/~~GVvI3lWnETLI_SIUzY95xw==/com.masu.washout-jnjK6gMTXdb3gAGq4kyBUA==/base.apk!classes6.dex)
                                                                                                    {"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":{"route_id":1234},"fastestLocationUpdateInterval":-1,"foregroundService":true,"geofenceInitialTriggerEntry":true,"geofenceModeHighAccuracy":false,"geofenceProximityRadius":1000,"geofenceTemplate":"","headers":{"my-auth-token":"secret-key"},"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":{"user_id":123},"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":"https:\/\/webhook.site\/1e2cb5f2-78d5-4bfc-b14d-706c0320ce31","useSignificantChangesOnly":false,"enabled":false,"schedulerEnabled":false,"trackingMode":1,"odometer":0,"isFirstBoot":false,"didLaunchInBackground":false,"didDeviceReboot":false}
                                                                                                    java.lang.IncompatibleClassChangeError: Found interface com.google.android.gms.location.FusedLocationProviderClient, but class was expected (declaration of 'com.google.android.gms.location.FusedLocationProviderClient' appears in /data/app/~~GVvI3lWnETLI_SIUzY95xw==/com.masu.washout-jnjK6gMTXdb3gAGq4kyBUA==/base.apk!classes6.dex)
                                                                                                        at com.transistorsoft.xms.g.location.FusedLocationProviderClient.removeLocationUpdates(Unknown Source:50)
                                                                                                        at com.transistorsoft.locationmanager.location.TSLocationManager.d(Unknown Source:40)
                                                                                                        at com.transistorsoft.locationmanager.location.TSLocationManager.stopUpdatingLocation(Unknown Source:0)
                                                                                                        at com.transistorsoft.locationmanager.location.TSLocationManager.stop(Unknown Source:0)
                                                                                                        at com.transistorsoft.locationmanager.service.TrackingService.stop(Unknown Source:83)
                                                                                                        at com.transistorsoft.locationmanager.adapter.BackgroundGeolocation.c(Unknown Source:2)
                                                                                                        at com.transistorsoft.locationmanager.adapter.BackgroundGeolocation.$r8$lambda$oSDeWXxQl1jmikdjYQwff60damw(Unknown Source:0)
2024-09-21 16:33:30.903 30076-30173 TSLocationManager       com.masu.washout                     E      at com.transistorsoft.locationmanager.adapter.BackgroundGeolocation$$ExternalSyntheticLambda1.run(Unknown Source:4)

Please learn to syntax highlight “fenced code blocks”

https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/creating-and-highlighting-code-blocks#fenced-code-blocks Logcat error:

E  FATAL EXCEPTION: pool-9-thread-1
                                                                                                    Process: com.masu.washout, PID: 30076
                                                                                                    java.lang.IncompatibleClassChangeError: Found interface com.google.android.gms.location.FusedLocationProviderClient, but class was expected (declaration of 'com.google.android.gms.location.FusedLocationProviderClient' appears in /data/app/~~GVvI3lWnETLI_SIUzY95xw==/com.masu.washout-jnjK6gMTXdb3gAGq4kyBUA==/base.apk!classes6.dex)
                                                                                                        at com.transistorsoft.xms.g.location.FusedLocationProviderClient.removeLocationUpdates(Unknown Source:50)
                                                                                                        at com.transistorsoft.locationmanager.location.TSLocationManager.d(Unknown Source:40)
                                                                                                        at com.transistorsoft.locationmanager.location.TSLocationManager.stopUpdatingLocation(Unknown Source:0)
                                                                                                        at com.transistorsoft.locationmanager.location.TSLocationManager.stop(Unknown Source:0)
                                                                                                        at com.transistorsoft.locationmanager.service.TrackingService.stop(Unknown Source:83)
                                                                                                        at com.transistorsoft.locationmanager.adapter.BackgroundGeolocation.c(Unknown Source:2)
                                                                                                        at com.transistorsoft.locationmanager.adapter.BackgroundGeolocation.$r8$lambda$oSDeWXxQl1jmikdjYQwff60damw(Unknown Source:0)
                                                                                                        at com.transistorsoft.locationmanager.adapter.BackgroundGeolocation$$ExternalSyntheticLambda1.run(Unknown Source:4)
                                                                                                        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
                                                                                                        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
                                                                                                        at java.lang.Thread.run(Thread.java:1012)
2024-09-21 16:33:30.903 30076-30173 TSLocationManager       com.masu.washout                     E  [c.t.l.a.BackgroundGeolocation$w0 uncaughtException] 
                                                                                                      ‼️  Uncaught Exception: Found interface com.google.android.gms.location.FusedLocationProviderClient, but class was expected (declaration of 'com.google.android.gms.location.FusedLocationProviderClient' appears in /data/app/~~GVvI3lWnETLI_SIUzY95xw==/com.masu.washout-jnjK6gMTXdb3gAGq4kyBUA==/base.apk!classes6.dex)
                                                                                                    {"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":{"route_id":1234},"fastestLocationUpdateInterval":-1,"foregroundService":true,"geofenceInitialTriggerEntry":true,"geofenceModeHighAccuracy":false,"geofenceProximityRadius":1000,"geofenceTemplate":"","headers":{"my-auth-token":"secret-key"},"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":{"user_id":123},"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":"https:\/\/webhook.site\/1e2cb5f2-78d5-4bfc-b14d-706c0320ce31","useSignificantChangesOnly":false,"enabled":false,"schedulerEnabled":false,"trackingMode":1,"odometer":0,"isFirstBoot":false,"didLaunchInBackground":false,"didDeviceReboot":false}
                                                                                                    java.lang.IncompatibleClassChangeError: Found interface com.google.android.gms.location.FusedLocationProviderClient, but class was expected (declaration of 'com.google.android.gms.location.FusedLocationProviderClient' appears in /data/app/~~GVvI3lWnETLI_SIUzY95xw==/com.masu.washout-jnjK6gMTXdb3gAGq4kyBUA==/base.apk!classes6.dex)
                                                                                                        at com.transistorsoft.xms.g.location.FusedLocationProviderClient.removeLocationUpdates(Unknown Source:50)
                                                                                                        at com.transistorsoft.locationmanager.location.TSLocationManager.d(Unknown Source:40)
                                                                                                        at com.transistorsoft.locationmanager.location.TSLocationManager.stopUpdatingLocation(Unknown Source:0)
                                                                                                        at com.transistorsoft.locationmanager.location.TSLocationManager.stop(Unknown Source:0)
                                                                                                        at com.transistorsoft.locationmanager.service.TrackingService.stop(Unknown Source:83)
                                                                                                        at com.transistorsoft.locationmanager.adapter.BackgroundGeolocation.c(Unknown Source:2)
                                                                                                        at com.transistorsoft.locationmanager.adapter.BackgroundGeolocation.$r8$lambda$oSDeWXxQl1jmikdjYQwff60damw(Unknown Source:0)
2024-09-21 16:33:30.903 30076-30173 TSLocationManager       com.masu.washout                     E      at com.transistorsoft.locationmanager.adapter.BackgroundGeolocation$$ExternalSyntheticLambda1.run(Unknown Source:4)
christocracy commented 1 day ago

@masucode duplicate #1710