react-native-background-geolocation icon indicating copy to clipboard operation
react-native-background-geolocation copied to clipboard

Android notification reappears after BackgroundGeolocation.stop() in android 14.

Open judeProground opened this issue 1 year ago • 10 comments

Your Environment

  • Plugin version: 4.16.2
  • Platform: Android
  • OS version: 14
  • Device manufacturer / model: Samsung Galaxy S21
  • React Native version (react-native -v): 0.72.10
  • Plugin config
    BackgroundGeolocation.ready({
      desiredAccuracy: BackgroundGeolocation.DESIRED_ACCURACY_HIGH,
      distanceFilter: filterValue, // 3000
      stopTimeout: 15,
      isMoving: true,
      foregroundService: true,
      showsBackgroundLocationIndicator: true,
      stopOnTerminate: true,
      startOnBoot: false,
      disableStopDetection: true,
      pausesLocationUpdatesAutomatically: false,

      notification: {
        title: 'MY_APP',
        text: 'Detecting ...',
        smallIcon: 'ic_notification',
        color: '#FD3D00',
      },

      locationAuthorizationRequest: 'WhenInUse',
      backgroundPermissionRationale: {
        title: t('app_inner_c.background_permission_title'),
        message: t('app_inner_c.background_permission_message'),
        positiveAction: t('app_inner_c.background_permission_action'),
      },
      locationAuthorizationAlert: {
        titleWhenNotEnabled: t('app_inner_c.location_alert_title'),
        titleWhenOff: t('app_inner_c.location_alert_title'),
        instructions: t('app_inner_c.location_alert_message'),
        cancelButton: t('app_inner_c.location_alert_cancel'),
        settingsButton: t('app_inner_c.location_alert_settings'),
      },
      maxRecordsToPersist: 2,
      disableLocationAuthorizationAlert: true,
      debug: false,
      logLevel: BackgroundGeolocation.LOG_LEVEL_OFF,
    });

Expected Behavior

After BackgroundGeolocation.stop(), the location service and notification in the Android status bar stop(disappear).

Actual Behavior

After BackgroundGeolocation.stop(), the location service and notification in the Android status bar stop(disappear), but then the notification reappears immediately.

Steps to Reproduce

  1. BackgroundGeolocation.ready() in App.tsx
  2. Here's the scheme of our app
RunningPage 

// when resume 
const startRunning = () => {
  BackgroundGeolocation.getProviderState(handlePermissionAbuse);
  // ...
};

// when pause
const stopRunning = () => {
  BackgroundGeolocation.destroyLocations();
}

useEffect(() => {
  BackgroundGeolocation.getCurrentPosition(config, onSuccess, onFailure)
}, [triggeredEveryTwoSeconds])

// on page mount
useEffect(() => {
  const locationProviderSubscription = BackgroundGeolocation.onProviderChange(handlePermissionAbuse)
  BackgroundGeolocation.start((state) => {
      if (state.enabled) BackgroundGeolocation.changePace(true);
    });

  return () => {
    locationProviderSubscription.remove();
    BackgroundGeolocation.changePace(false);
    BackgroundGeolocation.stop();
  }
}, [])

Context

Hi, christocracy! This seems to occur only on Android version 14, and I’m wondering if I might be missing some configuration settings.

Debug logs

Logs
06-04 20:13:04.221 21385 21655 D TSLocationManager: [c.t.l.u.LocationAuthorization withBackgroundPermission]
06-04 20:13:04.221 21385 21655 D TSLocationManager:   ℹ️  LocationAuthorization: Permission granted
06-04 20:13:04.224 21385 21640 I TSLocationManager: - Enable: false → true, trackingMode: 1
06-04 20:13:04.225 21385 21640 I TSLocationManager: [c.t.l.g.TSGeofenceManager start]
06-04 20:13:04.225 21385 21640 I TSLocationManager:   🎾  Start monitoring geofences
06-04 20:13:04.227 21385 21640 D TSLocationManager: [c.t.l.http.HttpService startMonitoringConnectivityChanges]
06-04 20:13:04.227 21385 21640 D TSLocationManager:   🎾  Start monitoring connectivity changes
06-04 20:13:04.235 21385 21640 D TSLocationManager: [c.t.l.device.DeviceSettings startMonitoringPowerSaveChanges]
06-04 20:13:04.235 21385 21640 D TSLocationManager:   🎾  Start monitoring powersave changes
06-04 20:13:04.244 21385 21640 I TSLocationManager: [c.t.l.s.ActivityRecognitionService start]
06-04 20:13:04.244 21385 21640 I TSLocationManager:   🎾  Start motion-activity updates
06-04 20:13:04.245 21385 21667 D TSLocationManager: [c.t.l.http.HttpService a]
06-04 20:13:04.245 21385 21667 D TSLocationManager: ╔═════════════════════════════════════════════
06-04 20:13:04.245 21385 21667 D TSLocationManager: ║ 📶  Connectivity change: connected? true
06-04 20:13:04.245 21385 21667 D TSLocationManager: ╠═════════════════════════════════════════════
06-04 20:13:04.257 21385 21640 I TSLocationManager: [c.t.l.service.HeartbeatService stop]
06-04 20:13:04.257 21385 21640 I TSLocationManager:   🔴  Stop heartbeat
06-04 20:13:04.262 21385 21640 I TSLocationManager: [c.t.l.service.TrackingService changePace]
06-04 20:13:04.262 21385 21640 I TSLocationManager:   🔵  setPace: false → false
06-04 20:13:04.312 21385 21640 D TSLocationManager: [c.t.l.adapter.TSConfig e] ℹ️   Persist config, dirty: [isMoving]
06-04 20:13:04.325 21385 21385 I TSLocationManager: [c.t.l.l.TSLocationManager a]
06-04 20:13:04.325 21385 21385 I TSLocationManager: ╔═════════════════════════════════════════════
06-04 20:13:04.325 21385 21385 I TSLocationManager: ║ motionchange LocationResult: 16 (10490ms old)
06-04 20:13:04.325 21385 21385 I TSLocationManager: ╠═════════════════════════════════════════════
06-04 20:13:04.325 21385 21385 I TSLocationManager: ╟─ 📍  Location[fused 37.480356,126.954092 hAcc=39.829 et=+20d16h55m52s852ms alt=59.60000228881836 vAcc=9.78114 vel=1.5976096 sAcc=1.5 bear=106.445564 bAcc=45.0], time: 1717499573834
06-04 20:13:04.327 21385 21640 I TSLocationManager: [c.t.l.service.HeartbeatService stop]
06-04 20:13:04.327 21385 21640 I TSLocationManager:   🔴  Stop heartbeat
06-04 20:13:04.329 21385 21385 I TSLocationManager: [c.t.l.l.TSLocationManager onSingleLocationResult]
06-04 20:13:04.329 21385 21385 I TSLocationManager:   🔵  Acquired motionchange position, isMoving: true
06-04 20:13:04.329 21385 21385 D TSLocationManager: [c.t.l.l.TSLocationManager a] Median accuracy: 24.772
06-04 20:13:04.345 21385 21385 I TSLocationManager: [c.t.l.l.TSLocationManager requestLocationUpdates]
06-04 20:13:04.345 21385 21385 I TSLocationManager:   🎾  Location-services: ON
06-04 20:13:04.346 21385 21385 D TSLocationManager: [c.t.l.adapter.TSConfig translateDesiredAccuracy] translateDesiredAccuracy (true): -1
06-04 20:13:04.347 21385 21640 I TSLocationManager: [c.t.l.service.TrackingService changePace]
06-04 20:13:04.347 21385 21640 I TSLocationManager:   🔵  setPace: false → true
06-04 20:13:04.357 21385 21640 I TSLocationManager: [c.t.l.d.s.SQLiteLocationDAO persist]
06-04 20:13:04.357 21385 21640 I TSLocationManager:   ✅  INSERT: 72eaea1e-6d79-49d3-a739-1045f166a20a
06-04 20:13:04.360 21385 21640 D TSLocationManager: [c.t.l.d.s.SQLiteLocationDAO shrink]
06-04 20:13:04.360 21385 21640 D TSLocationManager:   ℹ️  SHRINK: 2
06-04 20:13:04.399 21385 21385 D TSLocationManager: [c.t.l.service.AbstractService a]
06-04 20:13:04.399 21385 21385 D TSLocationManager:   🎾  motionchange [TrackingService  startId: 1, eventCount: 1]
06-04 20:13:04.400 21385 21385 I TSLocationManager: [c.t.l.service.TrackingService k]
06-04 20:13:04.400 21385 21385 I TSLocationManager: ╔═════════════════════════════════════════════
06-04 20:13:04.400 21385 21385 I TSLocationManager: ║ TrackingService motionchange: true
06-04 20:13:04.400 21385 21385 I TSLocationManager: ╠═════════════════════════════════════════════
06-04 20:13:04.401 21385 21385 D TSLocationManager: [c.t.l.service.AbstractService a]
06-04 20:13:04.401 21385 21385 D TSLocationManager:   ⚙️︎   FINISH [TrackingService startId: 1, eventCount: 0, sticky: true]
06-04 20:13:04.414 21385 21385 D TSLocationManager: [c.t.l.g.TSGeofenceManager startMonitoringStationaryRegion]
06-04 20:13:04.414 21385 21385 D TSLocationManager:   ℹ️  Cannot monitor stationary-region with 'WhenInUse' authorization
06-04 20:13:04.426 21385 21385 I TSLocationManager: [c.t.l.l.TSLocationManager a]
06-04 20:13:04.426 21385 21385 I TSLocationManager: ╔═════════════════════════════════════════════
06-04 20:13:04.426 21385 21385 I TSLocationManager: ║ motionchange LocationResult: 17 (10591ms old)
06-04 20:13:04.426 21385 21385 I TSLocationManager: ╠═════════════════════════════════════════════
06-04 20:13:04.426 21385 21385 I TSLocationManager: ╟─ 📍  Location[fused 37.480356,126.954092 hAcc=39.829 et=+20d16h55m52s852ms alt=59.60000228881836 vAcc=9.78114 vel=1.5976096 sAcc=1.5 bear=106.445564 bAcc=45.0], time: 1717499573834
06-04 20:13:04.428 21385 21385 I TSLocationManager: [c.t.l.l.TSLocationManager onSingleLocationResult]
06-04 20:13:04.428 21385 21385 I TSLocationManager:   🔵  Acquired motionchange position, isMoving: true
06-04 20:13:04.429 21385 21385 D TSLocationManager: [c.t.l.l.TSLocationManager a] Median accuracy: 24.772
06-04 20:13:04.438 21385 21385 I TSLocationManager: [c.t.l.l.TSLocationManager d]
06-04 20:13:04.438 21385 21385 I TSLocationManager:   🔴  Location-services: OFF
06-04 20:13:04.440 21385 21385 I TSLocationManager: [c.t.l.l.TSLocationManager requestLocationUpdates]
06-04 20:13:04.440 21385 21385 I TSLocationManager:   🎾  Location-services: ON
06-04 20:13:04.441 21385 21385 D TSLocationManager: [c.t.l.adapter.TSConfig translateDesiredAccuracy] translateDesiredAccuracy (true): -1
06-04 20:13:04.450 21385 21640 I TSLocationManager: [c.t.l.d.s.SQLiteLocationDAO persist]
06-04 20:13:04.450 21385 21640 I TSLocationManager:   ✅  INSERT: 5af94678-2d4f-4923-aaf6-04fd4dcc3376
06-04 20:13:04.456 21385 21640 D TSLocationManager: [c.t.l.d.s.SQLiteLocationDAO shrink]
06-04 20:13:04.456 21385 21640 D TSLocationManager:   ℹ️  SHRINK: 2
06-04 20:13:04.462 21385 21385 D TSLocationManager: [c.t.l.service.AbstractService a]
06-04 20:13:04.462 21385 21385 D TSLocationManager:   🎾  motionchange [TrackingService  startId: 2, eventCount: 1]
06-04 20:13:04.462 21385 21385 I TSLocationManager: [c.t.l.service.TrackingService k]
06-04 20:13:04.462 21385 21385 I TSLocationManager: ╔═════════════════════════════════════════════
06-04 20:13:04.462 21385 21385 I TSLocationManager: ║ TrackingService motionchange: true
06-04 20:13:04.462 21385 21385 I TSLocationManager: ╠═════════════════════════════════════════════
06-04 20:13:04.462 21385 21385 D TSLocationManager: [c.t.l.service.AbstractService a]
06-04 20:13:04.462 21385 21385 D TSLocationManager:   ⚙️︎   FINISH [TrackingService startId: 2, eventCount: 0, sticky: true]
06-04 20:13:04.507 21385 21385 D TSLocationManager: [c.t.l.service.AbstractService a]
06-04 20:13:04.507 21385 21385 D TSLocationManager:   🎾  start [ActivityRecognitionService  startId: 1, eventCount: 1]
06-04 20:13:04.509 21385 21640 D TSLocationManager: [c.t.l.s.ActivityRecognitionService a]
06-04 20:13:04.509 21385 21640 D TSLocationManager:   🚘 ️DetectedActivity [type=STILL, confidence=100]
06-04 20:13:04.511 21385 21385 I TSLocationManager: [c.t.l.s.ActivityRecognitionService start]
06-04 20:13:04.511 21385 21385 I TSLocationManager:   🎾  Start motion-activity updates
06-04 20:13:04.520 21385 21640 D TSLocationManager: [c.t.l.service.AbstractService a]
06-04 20:13:04.520 21385 21640 D TSLocationManager:   ⚙️︎   FINISH [ActivityRecognitionService startId: 1, eventCount: 0, sticky: false]
06-04 20:13:04.725 21385 21385 D TSLocationManager: [c.t.l.service.AbstractService f]
06-04 20:13:04.725 21385 21385 D TSLocationManager:   ⚙️︎  ActivityRecognitionService.stopSelfResult(1): true
06-04 20:13:04.727 21385 21385 D TSLocationManager: [c.t.l.service.AbstractService onDestroy]
06-04 20:13:04.727 21385 21385 D TSLocationManager:   🔴  ActivityRecognitionService stopped
06-04 20:13:08.100 21385 21385 D TSLocationManager: [c.t.l.service.AbstractService a]
06-04 20:13:08.100 21385 21385 D TSLocationManager:   🎾  start [TrackingService  startId: 3, eventCount: 1]
06-04 20:13:08.102 21385 21385 D TSLocationManager: [c.t.l.service.TrackingService c]
06-04 20:13:08.102 21385 21385 D TSLocationManager: ╔═════════════════════════════════════════════
06-04 20:13:08.102 21385 21385 D TSLocationManager: ║ TrackingService: LocationResult
06-04 20:13:08.102 21385 21385 D TSLocationManager: ╠═════════════════════════════════════════════
06-04 20:13:08.102 21385 21385 D TSLocationManager: ╟─ 📍  Location[fused 37.480726,126.954378 hAcc=26.977 et=+20d16h56m6s967ms alt=59.400001525878906 vAcc=9.781217 vel=3.3536837 sAcc=1.5 bear=32.065662 bAcc=45.0]
06-04 20:13:08.102 21385 21385 D TSLocationManager: ╟─ Age: 152ms, time: 1717499587949
06-04 20:13:08.103 21385 21640 D TSLocationManager: [c.t.l.l.TSLocationManager onLocationResult]
06-04 20:13:08.103 21385 21640 D TSLocationManager: ╔═════════════════════════════════════════════
06-04 20:13:08.103 21385 21640 D TSLocationManager: ║ Process LocationResult
06-04 20:13:08.103 21385 21640 D TSLocationManager: ╠═════════════════════════════════════════════
06-04 20:13:08.104 21385 21640 I TSLocationManager: [c.t.l.l.TSLocationManager onLocationResult]
06-04 20:13:08.104 21385 21640 I TSLocationManager:   🔵  Re-scaled distanceFilter: 1000000.0->2000000.0)
06-04 20:13:08.105 21385 21385 D TSLocationManager: [c.t.l.service.AbstractService a]
06-04 20:13:08.105 21385 21385 D TSLocationManager:   ⚙️︎   FINISH [TrackingService startId: 3, eventCount: 0, sticky: true]
06-04 20:13:08.106 21385 21640 D TSLocationManager: [c.t.l.l.TSLocationManager d] Distance from last location: 48.23128, apparent speed: 3.4170232
06-04 20:13:08.106 21385 21640 D TSLocationManager: [c.t.l.l.TSLocationManager a] Median accuracy: 24.772
06-04 20:13:08.107 21385 21640 D TSLocationManager: [c.t.l.l.TSLocationManager c] Odometer: 222.79738
06-04 20:13:08.124 21385 24183 I TSLocationManager: [c.t.l.d.s.SQLiteLocationDAO persist]
06-04 20:13:08.124 21385 24183 I TSLocationManager:   ✅  INSERT: 8e469123-3298-483d-9509-e00c4e3ab815
06-04 20:13:08.127 21385 24183 D TSLocationManager: [c.t.l.d.s.SQLiteLocationDAO shrink]
06-04 20:13:08.127 21385 24183 D TSLocationManager:   ℹ️  SHRINK: 2
06-04 20:13:08.170 21385 21385 D TSLocationManager: [c.t.l.service.AbstractService a]
06-04 20:13:08.170 21385 21385 D TSLocationManager:   🎾  start [TrackingService  startId: 4, eventCount: 1]
06-04 20:13:08.172 21385 21385 D TSLocationManager: [c.t.l.service.TrackingService c]
06-04 20:13:08.172 21385 21385 D TSLocationManager: ╔═════════════════════════════════════════════
06-04 20:13:08.172 21385 21385 D TSLocationManager: ║ TrackingService: LocationResult
06-04 20:13:08.172 21385 21385 D TSLocationManager: ╠═════════════════════════════════════════════
06-04 20:13:08.172 21385 21385 D TSLocationManager: ╟─ 📍  Location[fused 37.480726,126.954378 hAcc=26.977 et=+20d16h56m6s967ms alt=59.400001525878906 vAcc=9.781217 vel=3.3536837 sAcc=1.5 bear=32.065662 bAcc=45.0]
06-04 20:13:08.172 21385 21385 D TSLocationManager: ╟─ Age: 222ms, time: 1717499587949
06-04 20:13:08.172 21385 21385 D TSLocationManager: [c.t.l.service.AbstractService a]
06-04 20:13:08.172 21385 21385 D TSLocationManager:   ⚙️︎   FINISH [TrackingService startId: 4, eventCount: 0, sticky: true]
06-04 20:13:08.172 21385 24183 D TSLocationManager: [c.t.l.l.TSLocationManager onLocationResult]
06-04 20:13:08.172 21385 24183 D TSLocationManager: ╔═════════════════════════════════════════════
06-04 20:13:08.172 21385 24183 D TSLocationManager: ║ Process LocationResult
06-04 20:13:08.172 21385 24183 D TSLocationManager: ╠═════════════════════════════════════════════
06-04 20:13:08.173 21385 24183 D TSLocationManager: [c.t.l.l.TSLocationManager onLocationResult]
06-04 20:13:08.173 21385 24183 D TSLocationManager:   ℹ️  IGNORED: same as last location
06-04 20:13:10.360 21385 24183 D TSLocationManager: [c.t.l.adapter.TSConfig e] ℹ️   Persist config, dirty: [isMoving]
06-04 20:13:10.383 21385 24183 I TSLocationManager: [c.t.l.service.HeartbeatService stop]
06-04 20:13:10.383 21385 24183 I TSLocationManager:   🔴  Stop heartbeat
06-04 20:13:10.385 21385 21640 I TSLocationManager: [c.t.l.l.TSLocationManager d]
06-04 20:13:10.385 21385 21640 I TSLocationManager:   🔴  Location-services: OFF
06-04 20:13:10.394 21385 21640 D TSLocationManager: [c.t.l.l.TSLocationManager a]
06-04 20:13:10.394 21385 21640 D TSLocationManager:   ℹ️  Clear last odometer location
06-04 20:13:10.399 21385 21640 I TSLocationManager: [c.t.l.s.ActivityRecognitionService stop]
06-04 20:13:10.399 21385 21640 I TSLocationManager:   🔴  Stop motion-activity updates
06-04 20:13:10.399 21385 21643 D TSLocationManager: [c.t.l.g.TSGeofenceManager c]
06-04 20:13:10.399 21385 21643 D TSLocationManager:   🔴  Stop monitoring geofences
06-04 20:13:10.407 21385 21640 I TSLocationManager: [c.t.l.service.HeartbeatService stop]
06-04 20:13:10.407 21385 21640 I TSLocationManager:   🔴  Stop heartbeat
06-04 20:13:10.410 21385 21640 D TSLocationManager: [c.t.l.http.HttpService stopMonitoringConnectivityChanges]
06-04 20:13:10.410 21385 21640 D TSLocationManager:   🔴  Stop monitoring connectivity changes
06-04 20:13:10.414 21385 21640 D TSLocationManager: [c.t.l.device.DeviceSettings stopMonitoringPowerSaveChanges]
06-04 20:13:10.414 21385 21640 D TSLocationManager:   🔴  Stop monitoring powersave changes
06-04 20:13:10.426 21385 24183 I TSLocationManager: [c.t.l.service.TrackingService changePace]
06-04 20:13:10.426 21385 24183 I TSLocationManager:   🔵  setPace: true → false
06-04 20:13:10.449 21385 21385 D TSLocationManager: [c.t.l.service.AbstractService b]
06-04 20:13:10.449 21385 21385 D TSLocationManager:   🎾  STOP [TrackingService startId: 5, eventCount: 1]
06-04 20:13:10.449 21385 21385 D TSLocationManager: [c.t.l.service.AbstractService a]
06-04 20:13:10.449 21385 21385 D TSLocationManager:   ⚙️︎   FINISH [TrackingService startId: 5, eventCount: 0, sticky: false]
06-04 20:13:10.490 21385 21385 I TSLocationManager: [c.t.l.l.TSLocationManager a]
06-04 20:13:10.490 21385 21385 I TSLocationManager: ╔═════════════════════════════════════════════
06-04 20:13:10.490 21385 21385 I TSLocationManager: ║ motionchange LocationResult: 18 (2540ms old)
06-04 20:13:10.490 21385 21385 I TSLocationManager: ╠═════════════════════════════════════════════
06-04 20:13:10.490 21385 21385 I TSLocationManager: ╟─ 📍  Location[fused 37.480726,126.954378 hAcc=26.977 et=+20d16h56m6s967ms alt=59.400001525878906 vAcc=9.781217 vel=3.3536837 sAcc=1.5 bear=32.065662 bAcc=45.0], time: 1717499587949
06-04 20:13:10.496 21385 21385 I TSLocationManager: [c.t.l.l.TSLocationManager onSingleLocationResult]
06-04 20:13:10.496 21385 21385 I TSLocationManager:   🔵  Acquired motionchange position, isMoving: false
06-04 20:13:10.498 21385 21385 D TSLocationManager: [c.t.l.l.TSLocationManager a] Median accuracy: 24.772
06-04 20:13:10.547 21385 21385 D TSLocationManager: [c.t.l.g.TSGeofenceManager startMonitoringStationaryRegion]
06-04 20:13:10.547 21385 21385 D TSLocationManager:   ℹ️  Cannot monitor stationary-region with 'WhenInUse' authorization
06-04 20:13:10.587 21385 21385 W TSLocationManager: [c.t.l.service.AbstractService a]
06-04 20:13:10.587 21385 21385 W TSLocationManager:   ⚠️  Refusing to start TrackingService, enabled: false
06-04 20:13:10.587 21385 21385 D TSLocationManager: [c.t.l.service.AbstractService b]
06-04 20:13:10.587 21385 21385 D TSLocationManager:   🎾  STOP [TrackingService startId: 6, eventCount: 1]
06-04 20:13:10.588 21385 21385 D TSLocationManager: [c.t.l.service.AbstractService a]
06-04 20:13:10.588 21385 21385 D TSLocationManager:   ⚙️︎   FINISH [TrackingService startId: 6, eventCount: 0, sticky: false]
06-04 20:13:10.798 21385 21385 D TSLocationManager: [c.t.l.service.AbstractService f]
06-04 20:13:10.798 21385 21385 D TSLocationManager:   ⚙️︎  TrackingService.stopSelfResult(6): true
06-04 20:13:10.799 21385 21385 D TSLocationManager: [c.t.l.service.AbstractService onDestroy]
06-04 20:13:10.799 21385 21385 D TSLocationManager:   🔴  TrackingService stopped

judeProground avatar Jun 05 '24 01:06 judeProground

Likely because of this unnecessary and unawaited .changePace(false) before calling .stop().

BackgroundGeolocation.changePace(false);
BackgroundGeolocation.stop();

christocracy avatar Jun 05 '24 01:06 christocracy

Calling changePace can take several seconds to complete, where the plug-in waits for at least 3 locations to arrive, choosing the highest possible accuracy.

completely unnecessary when you’re just going to call .stop right after.

christocracy avatar Jun 05 '24 01:06 christocracy

Thank you for your response. I removed changePace, but the problem still persists. I will try a few more times!

judeProground avatar Jun 05 '24 01:06 judeProground

The problem is in your own code.

calling .getCurrentPosition launches a foreground service too.

christocracy avatar Jun 05 '24 01:06 christocracy

I made a simple switch that toggles start and stop, but the problem still exists.

Code
function SettingRunningPage() {
  const [switchValue, setSwitchValue] = useState(false);
  const [changedPace, setChangedPace] = useState(false);

  const onChangeValue = async (newValue: boolean) => {
    if (newValue) {
      BackgroundGeolocation.start((state) => {
        if (state.enabled) {
          BackgroundGeolocation.changePace(true, () => {
            setChangedPace(true);
          });
        }
      });
    } else {
      BackgroundGeolocation.stop(
        (s) => {
          console.log(s);
          setChangedPace(false);
        },
        (e) => {
          console.log(e);
        },
      );
    }
    setSwitchValue(newValue);
  };

  return (
    <AppLayout Header={<NormalHeader title={'BackgroundGeolocation'} />} backgroundColor={COLORS.white} safeAreaEnabled>
      <View style={{ flex: 1, backgroundColor: COLORS.white, paddingTop: 16 }}>
        <SettingRow title={'BackgroundGeolocation'}>
          <SwitchButton value={switchValue} onChangeValue={onChangeValue} />
          <Text type="Body1_400">{`changedPace: ${changedPace}`}</Text>
        </SettingRow>
      </View>
    </AppLayout>
  );
}

https://github.com/transistorsoft/react-native-background-geolocation/assets/122759638/ca7388cb-c836-43e3-a7e9-8d21bad08b8b

judeProground avatar Jun 05 '24 02:06 judeProground

You do not need to .changePace when you’re calling .stop()!!

calling .stop() stops everything.

Just delete all calls to .changePace when you’re stopping the plug-in.

christocracy avatar Jun 05 '24 02:06 christocracy

It's not BackgroundGeolocation.changePace, It's just useState setState to show the text changedPace

judeProground avatar Jun 05 '24 02:06 judeProground

Create for me a simple hello-world in a freshly generated app which reproduces it. Share it with me in a public GitHub repo.

christocracy avatar Jun 05 '24 02:06 christocracy

If this is not enough, I would like to suggest creating a forkable Hello World app with all the settings configured. This would make it easier for other users to create reproducible examples as well.

I’ll try to create a Hello World app and let you know

judeProground avatar Jun 05 '24 02:06 judeProground

If this is not enough

No. I believe the problem is in your own code.

christocracy avatar Jun 05 '24 03:06 christocracy

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

github-actions[bot] avatar Jul 06 '24 01:07 github-actions[bot]

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

github-actions[bot] avatar Jul 20 '24 01:07 github-actions[bot]