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

Tracking not working on Android 10

Open redwind opened this issue 3 years ago • 3 comments
trafficstars

Your Environment

  • Plugin version: 4.4.4
  • Platform: Android
  • OS version: 10.0
  • Device manufacturer / model: Samsung A10
  • React Native version (react-native -v): 0.63.4
  • Plugin config
{
          locationAuthorizationRequest: 'Always',
          reset: true,
          // Geolocation Config
          desiredAccuracy: BackgroundGeolocation.DESIRED_ACCURACY_HIGH,
          locationTemplate:
            '{"uuid":\'<%=uuid%>\',"event":\'<%=event%>\',"accuracy":<%=accuracy%>,"is_moving":<%=is_moving%>,"mocked":<%=mock%>,"latitude":<%=latitude%>,"longitude":<%=longitude%>,"odometer":<%=odometer%>,"speed":<%=speed%>,"heading":<%=heading%>,"altitude_accuracy":<%=altitude_accuracy%>,"altitude":<%=altitude%>,"activity_type":"<%=activity.type%>","activity_confidence":"<%=activity.confidence%>","battery_level":"<%=battery.level%>","timestamp":"<%=timestamp%>"}',
          distanceFilter: distanceTracking,
          scheduleUseAlarmManager: true,
          // Application config
          logMaxDays: 2,
          stopOnTerminate: false, // <-- Allow the background-service to continue tracking when user closes the app.
          startOnBoot: true, // <-- Auto start tracking when device is powered-up.
          enableHeadless: false,  
          heartbeatInterval: 60,
          stopTimeout: 5,
          backgroundPermissionRationale: {
            title: utils
              .getIntl()
              .formatMessage(Messages.background_permission_rationale_title),
            message: utils
              .getIntl()
              .formatMessage(Messages.background_permission_rationale_message),
            positiveAction: utils
              .getIntl()
              .formatMessage(
                Messages.background_permission_rationale_positiveAction,
              ),
            negativeAction: utils.getIntl().formatMessage(Messages.cancel),
          },
          batchSync: true, // <-- [Default: false] Set true to sync locations to server in a single HTTP request.
          autoSync: true, // <-- [Default: true] Set true to sync each location to server as it arrives.
          autoSyncThreshold: 2,
          notification: {
            sticky: true,
            title: 'XXXX',
            text: utils
              .getIntl()
              .formatMessage(Messages.notification_tracking_desc),
          },
          url,    
          logLevel,
          headers: {
            // <-- Optional HTTP headers
            Authorization: 'Bearer ' + user.apiToken,
          },
          params: {
           
          },
          maxDaysToPersist: 5,
          isMoving: true,
        },

Hi @christocracy , i tested on 2 samsung device but i don't know why it's not tracking on my device running android 10.

  1. Samsung galaxy A10 running android 10
  2. Samsung S8 running android 9

Are there any thing wrong in my config ?

Thanks !!!

Expected Behavior

  • Devices tracking my location on moving

Actual Behavior

  • Samsung S8 with android 9 track all my moving location but Samsung gallaxy A10 with android 10 is not

Steps to Reproduce

  1. start background geolocation service then turn off device display
  2. put all devices to my backpack
  3. running motobike about 9km

Context

My app tracking employee moving when they clock-in to their working time.

Debug logs

I also add this to AndroidManifest.xml

<uses-permission android:name="android.permission.ACTIVITY_RECOGNITION" />
03-24 16:23:58.442 DEBUG [LoggerFacade$a a] ℹ️   Persist config, dirty: []
03-24 16:23:58.444 DEBUG [LoggerFacade$a a] ℹ️   Persist config, dirty: [headlessJobService]
03-24 16:23:58.686 INFO [BackgroundGeolocation <init>] 
  ✅  Google Play Services: connected (version code:12451000)
03-24 16:23:58.736 INFO [BackgroundGeolocation d] 
  🎾  Start monitoring location-provider changes
03-24 16:23:58.838 DEBUG [a onCreate] CREATE TABLE IF NOT EXISTS locations (id INTEGER PRIMARY KEY AUTOINCREMENT, uuid TEXT NOT NULL DEFAULT '', timestamp TEXT, json TEXT, data BLOB, encrypted BOOLEAN NOT NULL DEFAULT 0, locked BOOLEAN NOT NULL DEFAULT 0);
03-24 16:23:58.840 DEBUG [a onCreate] CREATE TABLE IF NOT EXISTS geofences (id INTEGER PRIMARY KEY AUTOINCREMENT, identifier TEXT NOT NULL UNIQUE, latitude DOUBLE NOT NULL, sin_latitude DOUBLE NOT NULL, cos_latitude DOUBLE NOT NULL, longitude DOUBLE NOT NULL, sin_longitude DOUBLE NOT NULL, cos_longitude DOUBLE NOT NULL, radius DOUBLE NOT NULL, notifyOnEntry BOOLEAN NOT NULL DEFAULT 0, notifyOnExit BOOLEAN NOT NULL DEFAULT 0, notifyOnDwell BOOLEAN NOT NULL DEFAULT 0, loiteringDelay INTEGER NOT NULL DEFAULT 0, extras TEXT);
03-24 16:23:58.863 DEBUG [b prune] 
  ℹ️  PRUNE -1 days
03-24 16:25:49.453 DEBUG [TSConfig d] ℹ️   Persist config, dirty: [autoSyncThreshold, backgroundPermissionRationale, backgroundPermissionRationale.title, backgroundPermissionRationale.message, backgroundPermissionRationale.positiveAction, backgroundPermissionRationale.negativeAction, batchSync, desiredAccuracy, distanceFilter, headers, heartbeatInterval, isMoving, locationTemplate, logLevel, logMaxDays, maxDaysToPersist, notification, notification.title, notification.text, notification.sticky, params, scheduleUseAlarmManager, startOnBoot, stopOnTerminate, url]
03-24 16:25:49.476 INFO [HttpService flush] 
╔═════════════════════════════════════════════
║ HTTP Service (count: 0)
╠═════════════════════════════════════════════

03-24 16:25:49.955 INFO [c g] 
  🔵  LocationAuthorization: Requesting Background permission
03-24 16:25:53.365 INFO [c$k onPermissionGranted] 
  ✅  LocationAuthorization: Permission granted
03-24 16:25:53.409 INFO [ActivityRecognitionService b] 
  🎾  Start motion-activity updates
03-24 16:25:53.425 DEBUG [HttpService startMonitoringConnectivityChanges] 
  🎾  Start monitoring connectivity changes
03-24 16:25:53.433 DEBUG [a c] 
  🎾  Start monitoring powersave changes
03-24 16:25:53.448 DEBUG [HttpService a] 
╔═════════════════════════════════════════════
║ 📶  Connectivity change: connected? true
╠═════════════════════════════════════════════

03-24 16:25:53.452 DEBUG [TSLocationManagerActivity execute] locationsettings
03-24 16:25:53.456 INFO [HeartbeatService c] 
  🔴  Stop heartbeat
03-24 16:25:53.458 DEBUG [TSConfig translateDesiredAccuracy] translateDesiredAccuracy (true): -1
03-24 16:25:53.464 DEBUG [c h] 
  ℹ️  LocationAuthorization: Permission granted
03-24 16:25:53.471 INFO [TrackingService a] 
  🔵  setPace: true → true
03-24 16:25:53.605 DEBUG [AbstractService a] 
  🎾  TrackingService [eventCount: 1]
03-24 16:25:53.607 INFO [TrackingService h] 
╔═════════════════════════════════════════════
║ TrackingService motionchange: true
╠═════════════════════════════════════════════

03-24 16:25:53.608 DEBUG [AbstractService a] ⚙️︎  finish TrackingService [eventCount: 0, sticky: true]
03-24 16:25:53.664 DEBUG [TSLocationManagerActivity stop] eventCount: 0
03-24 16:25:53.755 DEBUG [AbstractService a] 
  🎾  LocationRequestService [eventCount: 1]
03-24 16:25:53.757 INFO [LocationRequestService b] 
╔═════════════════════════════════════════════
║ motionchange LocationResult: 1
╠═════════════════════════════════════════════
╟─ 📍  Location[fused 10,815759,106,697275 hAcc=16 et=+9h17m13s870ms alt=20.19999885559082 vAcc=1 sAcc=??? bAcc=??? {Bundle[mParcelledData.dataSize=636]}], age: 103ms, time: 1648113953654

03-24 16:25:53.760 INFO [TSLocationManager onSingleLocationResult] 
  🔵  Acquired motionchange position, isMoving: true
03-24 16:25:53.761 DEBUG [TSLocationManager calculateMedianAccuracy] Median accuracy: 15.982
03-24 16:25:53.795 DEBUG [TSLocationManagerActivity onDestroy] 
03-24 16:25:53.835 DEBUG [AbstractService a] ⚙️︎  finish LocationRequestService [eventCount: 0, sticky: false]
03-24 16:25:53.859 DEBUG [AbstractService onDestroy] 
  🔴  LocationRequestService destroyed
03-24 16:25:53.943 INFO [TSLocationManager requestLocationUpdates] 
  🎾  Location-services: ON
03-24 16:25:53.946 INFO [TSLocationManager requestLocationUpdates] 
  🎾  Location-services: ON
03-24 16:25:53.949 DEBUG [TSConfig translateDesiredAccuracy] translateDesiredAccuracy (true): -1
03-24 16:25:53.957 DEBUG [LocationRequestService b] SingleLocationRequest 1 isFinished? true
03-24 16:25:53.958 INFO [ActivityRecognitionService b] 
  🎾  Start motion-activity updates
03-24 16:25:53.959 DEBUG [AbstractService a] ⚙️︎  finish LocationRequestService [eventCount: 0, sticky: false]
03-24 16:25:53.962 INFO [TSLocationManager removeLocationUpdates] 
  🔴  Location-services: OFF
03-24 16:25:53.965 INFO [TSLocationManager requestLocationUpdates] 
  🎾  Location-services: ON
03-24 16:25:53.971 DEBUG [TSConfig translateDesiredAccuracy] translateDesiredAccuracy (true): -1
03-24 16:25:54.001 INFO [b persist] 
  ✅  INSERT: 64b2b914-3a74-4311-bbbb-4296dcfc1589
03-24 16:25:54.024 INFO [HttpService flush] 
╔═════════════════════════════════════════════
║ HTTP Service (count: 1)
╠═════════════════════════════════════════════

03-24 16:25:54.115 DEBUG [AbstractService a] 
  🎾  TrackingService [eventCount: 1]
03-24 16:25:54.117 DEBUG [TrackingService b] 
╔═════════════════════════════════════════════
║ TrackingService: LocationResult
╠═════════════════════════════════════════════
╟─ 📍  Location[fused 10,815759,106,697275 hAcc=16 et=+9h17m14s23ms alt=20.19999885559082 vAcc=1 sAcc=??? bAcc=??? {Bundle[mParcelledData.dataSize=636]}], age: 309ms, time: 1648113953807

03-24 16:25:54.118 DEBUG [TSLocationManager onLocationResult] 
╔═════════════════════════════════════════════
║ Process LocationResult
╠═════════════════════════════════════════════

03-24 16:25:54.118 DEBUG [AbstractService a] ⚙️︎  finish TrackingService [eventCount: 0, sticky: true]
03-24 16:25:54.119 DEBUG [TSLocationManager onLocationResult] 
  ℹ️  IGNORED: same as last location
03-24 16:25:54.146 DEBUG [AbstractService a] 
  🎾  BackgroundTaskService [eventCount: 1]
03-24 16:25:54.147 INFO [BackgroundTaskManager onStartJob] ⏳ startBackgroundTask: 1
03-24 16:25:54.167 DEBUG [b allWithLocking] 
  ✅  Locked 1 records
03-24 16:25:54.169 INFO [HttpService a] 
  🔵  HTTP POST batch (1)
03-24 16:25:54.205 DEBUG [AbstractService a] 
  🎾  ActivityRecognitionService [eventCount: 1]
03-24 16:25:54.208 DEBUG [ActivityRecognitionService a] 
  🚘 ️DetectedActivity [type=STILL, confidence=100]
03-24 16:25:54.216 DEBUG [AbstractService a] ⚙️︎  finish ActivityRecognitionService [eventCount: 0, sticky: true]
03-24 16:25:54.316 DEBUG [AbstractService a] 
  🎾  TrackingService [eventCount: 1]
03-24 16:25:54.318 DEBUG [TrackingService b] 
╔═════════════════════════════════════════════
║ TrackingService: LocationResult
╠═════════════════════════════════════════════
╟─ 📍  Location[fused 10,815759,106,697275 hAcc=16 et=+9h17m14s376ms alt=20.19999885559082 vAcc=1 sAcc=??? bAcc=??? {Bundle[mParcelledData.dataSize=636]}], age: 157ms, time: 1648113954160

03-24 16:25:54.319 DEBUG [TSLocationManager onLocationResult] 
╔═════════════════════════════════════════════
║ Process LocationResult
╠═════════════════════════════════════════════

03-24 16:25:54.320 DEBUG [TSLocationManager onLocationResult] 
  ℹ️  IGNORED: same as last location
03-24 16:25:54.327 INFO [TSScheduleManager oneShot] 
  ⏰ Scheduled OneShot: STOP_TIMEOUT in 300000ms (jobID: 2059034116)
03-24 16:25:54.341 DEBUG [AbstractService a] ⚙️︎  finish TrackingService [eventCount: 0, sticky: true]
03-24 16:25:54.453 INFO [HttpService flush] 
  ℹ️  HttpService is busy
03-24 16:25:54.731 INFO [HttpService$i onResponse] 
  🔵  Response: 200
03-24 16:25:54.737 DEBUG [b destroyAll] 
  ✅  DELETED: (1)
03-24 16:25:54.745 DEBUG [b allWithLocking] 
  ✅  Locked 0 records
03-24 16:25:54.747 INFO [BackgroundTaskManager$Task stop] ⏳ stopBackgroundTask: 1
03-24 16:25:54.749 DEBUG [AbstractService a] ⚙️︎  finish BackgroundTaskService [eventCount: 0, sticky: false]
03-24 16:25:54.755 DEBUG [AbstractService onDestroy] 
  🔴  BackgroundTaskService destroyed
03-24 16:26:10.420 INFO [TSScheduleManager oneShot] 
  ⏰ Scheduled OneShot: TERMINATE_EVENT in 10000ms (jobID: -1708771588)
03-24 16:26:20.460 INFO [ScheduleEvent onOneShot] 
╔═════════════════════════════════════════════
║ ⏰ OneShot event fired: TERMINATE_EVENT
╠═════════════════════════════════════════════

03-24 16:26:20.468 DEBUG [TerminateEvent <init>] 
  ℹ️  TERMINATE_EVENT ignored (MainActivity is still active).
03-24 16:28:46.497 DEBUG [HttpService a] 
╔═════════════════════════════════════════════
║ 📶  Connectivity change: connected? false
╠═════════════════════════════════════════════

03-24 16:33:46.091 INFO [ScheduleEvent onOneShot] 
╔═════════════════════════════════════════════
║ ⏰ OneShot event fired: STOP_TIMEOUT
╠═════════════════════════════════════════════

03-24 16:33:46.115 DEBUG [TSConfig d] ℹ️   Persist config, dirty: [isMoving]
03-24 16:33:46.124 INFO [TSLocationManager removeLocationUpdates] 
  🔴  Location-services: OFF
03-24 16:33:46.132 INFO [HeartbeatService b] 
  🎾  Start heartbeat (60s)
03-24 16:33:46.152 DEBUG [c h] 
  ℹ️  LocationAuthorization: Permission granted
03-24 16:33:46.153 INFO [TrackingService a] 
  🔵  setPace: true → false
03-24 17:07:33.060 DEBUG [HttpService a] 
╔═════════════════════════════════════════════
║ 📶  Connectivity change: connected? true
╠═════════════════════════════════════════════

03-24 17:07:34.067 INFO [HttpService flush] 
╔═════════════════════════════════════════════
║ HTTP Service (count: 0)
╠═════════════════════════════════════════════

03-24 17:07:34.164 WARN [RNBackgroundGeolocationModule ready] 
  ⚠️  #ready already called.  Redirecting to #setConfig
03-24 17:07:34.196 DEBUG [TSConfig d] ℹ️   Persist config, dirty: [headers, isMoving, params]
03-24 17:07:34.213 INFO [HttpService flush] 
╔═════════════════════════════════════════════
║ HTTP Service (count: 0)
╠═════════════════════════════════════════════

03-24 17:07:34.515 WARN [RNBackgroundGeolocationModule ready] 
  ⚠️  #ready already called.  Redirecting to #setConfig
03-24 17:07:34.538 DEBUG [TSConfig d] ℹ️   Persist config, dirty: [headers, params]
03-24 17:07:34.552 INFO [HttpService flush] 
╔═════════════════════════════════════════════
║ HTTP Service (count: 0)
╠═════════════════════════════════════════════

03-24 17:07:34.890 WARN [RNBackgroundGeolocationModule ready] 
  ⚠️  #ready already called.  Redirecting to #setConfig
03-24 17:07:34.912 DEBUG [TSConfig d] ℹ️   Persist config, dirty: [headers, params]
03-24 17:07:34.925 INFO [HttpService flush] 
╔═════════════════════════════════════════════
║ HTTP Service (count: 0)
╠═════════════════════════════════════════════

03-24 17:14:44.233 DEBUG [AbstractService a] 
  🎾  HeartbeatService [eventCount: 1]
03-24 17:14:44.234 DEBUG [HeartbeatService$a run] ❤️
03-24 17:14:44.281 DEBUG [AbstractService a] ⚙️︎  finish HeartbeatService [eventCount: 0, sticky: false]
03-24 17:14:44.536 DEBUG [AbstractService onDestroy] 
  🔴  HeartbeatService destroyed
03-24 17:14:58.900 INFO [TSScheduleManager oneShot] 
  ⏰ Scheduled OneShot: TERMINATE_EVENT in 10000ms (jobID: -1708771588)
03-24 17:15:03.985 DEBUG [AbstractService a] 
  🎾  HeartbeatService [eventCount: 1]
03-24 17:15:03.987 DEBUG [HeartbeatService$a run] ❤️
03-24 17:15:04.007 DEBUG [AbstractService a] ⚙️︎  finish HeartbeatService [eventCount: 0, sticky: false]
03-24 17:15:04.271 DEBUG [AbstractService onDestroy] 
  🔴  HeartbeatService destroyed
03-24 17:15:08.951 INFO [ScheduleEvent onOneShot] 
╔═════════════════════════════════════════════
║ ⏰ OneShot event fired: TERMINATE_EVENT
╠═════════════════════════════════════════════

03-24 17:15:08.959 DEBUG [TerminateEvent <init>] 
  ℹ️  TERMINATE_EVENT ignored (MainActivity is still active).
03-24 17:16:05.376 WARN [SingleLocationRequest finish] 
  ⚠️  timeout: 2
03-24 17:16:05.380 WARN [TSLocationManager onLocationTimeout] 
  ⚠️  TSLocationManager received location timeout
03-24 17:16:05.385 WARN [BackgroundGeolocation _onLocationError] 
  ⚠️  Location error: 408
03-24 17:16:05.392 INFO [ActivityRecognitionService b] 
  🎾  Start motion-activity updates
03-24 17:16:05.471 DEBUG [AbstractService a] ⚙️︎  finish LocationRequestService [eventCount: 0, sticky: false]
03-24 17:16:05.476 DEBUG [AbstractService onDestroy] 
  🔴  LocationRequestService destroyed

redwind avatar Mar 25 '22 04:03 redwind

See https://dontkillmyapp.com

christocracy avatar Mar 25 '22 14:03 christocracy

See https://dontkillmyapp.com

thanks for your reply, i've also check battery save mode and disable it follow by this but it's still not work. Let me try more setting from dontkillmyapp as your suggestion. Thanks !!! Screenshot 2017-09-19 10 33 49

redwind avatar Mar 26 '22 01:03 redwind

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. You may also mark this issue as a "discussion" and I will leave this open.

stale[bot] avatar Jun 12 '22 19:06 stale[bot]

Closing this issue after a prolonged period of inactivity. Fell free to reopen this issue, if this still affecting you.

stale[bot] avatar Sep 21 '22 04:09 stale[bot]