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

iOS: the application is unable to stay alive in the background with "When in use" privacy.

Open ironmanromeo opened this issue 3 years ago • 2 comments

Your Environment

  • Plugin version: ^4.4.4
  • Platform: iOS
  • OS version: 15.2.1
  • Device manufacturer / model: iPhone 13 PRO, iPhone 6S, iPhone X, iPhone 12
  • React Native version (react-native -v):r eact-native-cli: 2.0.1 - react-native: 0.64.3
  • Plugin config
{
    desiredAccuracy: BackgroundGeolocation.DESIRED_ACCURACY_NAVIGATION,
    preventSuspend: true,
    heartbeatInterval: 60,
    stopTimeout: 60*10,
    locationAuthorizationRequest: 'WhenInUse',
    debug: false,
    logLevel: BackgroundGeolocation.LOG_LEVEL_VERBOSE,
    //transistorAuthorizationToken: token,
    distanceFilter: 10,
    isMoving:true,
    pausesLocationUpdatesAutomatically:false,
    showsBackgroundLocationIndicator:true,
    disableStopDetection:true
}

Expected Behavior

That the plug-in works with "When in use"

Actual Behavior

It does not work as expected: application goes in sleep mode and stop tracking

Steps to Reproduce

  1. Turn on the service
  2. Put the app in the background
  3. Put the app in the foreground
  4. Stop the service
  5. Restart the service
  6. Put the app in the background again
  7. After a while the blue symbol of the app disappears, identifying the geolog service is not in the background anymore

Context

OUT MILESTONE: allow the application to work on the iOS and Android side with the "When in use" and not "Always" permission.

We must achieve the goal provided by competing applications that allow you to stay with the app in the background without being closed by the system. We tried various configurations without achieving the desired goal.

We have read several times the document https://github.com/transistorsoft/react-native-background-geolocation/wiki/Philosophy-of-Operation which refers to the "Always" permission, where the application is terminated by the system and reactivated when you need to manage an event.

const MacSettings = { desiredAccuracy: BackgroundGeolocation.DESIRED_ACCURACY_NAVIGATION, preventSuspend: true, heartbeatInterval: 60, locationAuthorizationRequest: 'WhenInUse', debug: false, logLevel: BackgroundGeolocation.LOG_LEVEL_VERBOSE, //transistorAuthorizationToken: token, distanceFilter: 10, isMoving:true, showsBackgroundLocationIndicator:true, }

const state = await BackgroundGeolocation.ready(MacSettings)

TS MILESTONE: .ready

We have verified that "ready" is called at startup only once as noted in this note: "⚠️ Warning: You must call #ready once and only once, each time your app is launched.”

We call the ready inside a useEffect with an empty array dependency, exactly as we do in the example application.

FIRST TRY: iOS preventSuspend mode

Reading the documentation it would seem that with this setting alone the application should never go into a "suspended" state even though the tracking service is not always on (GPS off). The documentation mentions no use of "black magic", but does not specify exactly what the plug-in does to stay active at all times. From our tests we understand that the plug-in uses the "CoreMotion" framework to turn the service on and off. During this period, however, the service should always remain active and never send the application "suspended". Unfortunately this does not happen and after a certain period of time the blue box identifying the active background tracking service goes out and the application stops tracking.

From what we understand "black magic" consists of this event that is sent by default every minute: "While in the #preventSuspend mode in the stationary state, the plugin is able to fire a heartbeat event periodically (#heartbeatInterval). The heartbeat event will fire your Javascript callback:"

So the "preventSuspend" should be: if the user moves the plug-in via CoreMotion he turns off the heartbeat event and switches the tracking back on (GPS on), if he stops the plug-in he notices that there is no more movement and stop tracking (GPS off), from that moment a poll on a background task starts to keep the application alive. This should be the "clever and acceptable" way to keep the application alive.

bgGeo.configure ({ preventSuspend: true, heartbeatInterval: 60, // <- every minute stopOnTerminate: false, debug: true });

What we discovered is that if we leave it in debug it "seems" to actually stay in this state, if we turn off debugging unfortunately it doesn't.

After reporting this issue to the developer we get this as an answer: “See api docs Config.pausesLocationUpdatesAutomatically”

SECOND TRY: Config.pausesLocationUpdatesAutomatically

We have therefore added (first by itself and then with the other settings) the aforementioned parameter. According to what is written, the plug-in makes useless the activation and deactivation mechanism of the service which is always "on". Unfortunately, even in this case, after an indefinite period of time, the service switches off.

const MacSettings = { desiredAccuracy: BackgroundGeolocation.DESIRED_ACCURACY_NAVIGATION, preventSuspend: true, heartbeatInterval: 60, locationAuthorizationRequest: 'WhenInUse', debug: false, logLevel: BackgroundGeolocation.LOG_LEVEL_VERBOSE, //transistorAuthorizationToken: token, distanceFilter: 10, isMoving:true, pausesLocationUpdatesAutomatically:false, showsBackgroundLocationIndicator:true, disableStopDetection:true }

THIRD TRY: changePace(true)

Based on a response from the support team we tried to interpret this sentence: "When you use WhenInUse, the plugin will remain tracking until you .stop (), .changePace (false) or Config.stopTimeout expires."

BackgroundGeolocation.changePace(true); // <-- Location-services ON ("moving" state)

In theory changePace(true) combined with pausesLocationUpdatesAutomatically:false should (logically) keep the service active as if we were always on the move. Unfortunately this does not happen either.

FOURTH TRY: stopTimeout: 60*10

After trying to bring this value to a maximum of 15 minutes as a timeout and discovering that after that time the plug-in stopped, we tried to keep the service active by extending the time to 10 hours (60 * 10). Not even this solution has had a positive effect.

What we discovered is that if we leave it in debug mode on it "seems" to actually stay in this state, if we turn off debugging unfortunately it doesn't.

The latest version of the configuration is this.

const MacSettings = { desiredAccuracy: BackgroundGeolocation.DESIRED_ACCURACY_NAVIGATION, preventSuspend: true, heartbeatInterval: 60, stopTimeout: 60*10, locationAuthorizationRequest: 'WhenInUse', debug: false, logLevel: BackgroundGeolocation.LOG_LEVEL_VERBOSE, //transistorAuthorizationToken: token, distanceFilter: 10, isMoving:true, pausesLocationUpdatesAutomatically:false, showsBackgroundLocationIndicator:true, disableStopDetection:true }

SUMMING UP

Unfortunately, this time (about a month of tests) is lengthening the application release time and the tests we are doing on the Android side unfortunately also show the same problem here. But before addressing the problem on the Android front we would prefer (always possible) to conclude the iOS part with your help.

The first question we haven't had an official answer yet is: is the plug-in capable of working with privacy "When in use" on both iOS and Android? From our e-mails it seemed so and we made our client buy the Android license.

The second question we ask you is: if it is not clear from the documentation what kind of configuration is needed to get what we need, can you provide it? Is this information part of the paid support of the multiple license?

Debug logs

Logs

{
activityRecognitionInterval = 10000;
activityType = 1;
authorization = {
};
autoSync = 1;
autoSyncThreshold = 0;
batchSync = 0;
debug = 0;
desiredAccuracy = "-2";
desiredOdometerAccuracy = 100;
didDeviceReboot = 0;
didLaunchInBackground = 0;
didRequestUpgradeLocationAuthorization = 0;
disableAutoSyncOnCellular = 0;
disableElasticity = 0;
disableLocationAuthorizationAlert = 0;
disableMotionActivityUpdates = 0;
disableStopDetection = 1;
distanceFilter = 10;
elasticityMultiplier = 1;
enableTimestampMeta = 0;
enabled = 0;
extras = {
};
geofenceInitialTriggerEntry = 1;
geofenceProximityRadius = 2000;
geofenceTemplate = "";
headers = {
};
heartbeatInterval = 60;
httpRootProperty = location;
httpTimeout = 60000;
iOSHasWarnedLocationServicesOff = 0;
isFirstBoot = 1;
isMoving = 0;
lastLocationAuthorizationStatus = 4;
locationAuthorizationAlert = {
cancelButton = Cancel;
instructions = "To use background location, you must enable '{locationAuthorizationRequest}' in the Location Services settings";
settingsButton = Settings;
titleWhenNotEnabled = "Background location is not enabled";
titleWhenOff = "Location services are off";
};
locationAuthorizationRequest = WhenInUse;
locationTemplate = "";
locationTimeout = 60;
locationsOrderDirection = ASC;
logLevel = 5;
logMaxDays = 3;
maxBatchSize = "-1";
maxDaysToPersist = 1;
maxRecordsToPersist = "-1";
method = POST;
minimumActivityRecognitionConfidence = 70;
odometer = "540.97063451088";
params = {
};
pausesLocationUpdatesAutomatically = 0;
persistMode = 2;
preventSuspend = 1;
schedule = (
);
schedulerEnabled = 0;
showsBackgroundLocationIndicator = 0;
startOnBoot = 0;
stationaryRadius = 25;
stopAfterElapsedMinutes = "-1";
stopDetectionDelay = 0;
stopOnStationary = 0;
stopOnTerminate = 1;
stopTimeout = 600;
trackingMode = 1;
url = "";
useSignificantChangesOnly = 0;
}



2022-02-01 14:28:50.482 ℹ️-[TSConfig persist] 

2022-02-01 14:28:50.484 🔵-[TSLocationManager ready] 

2022-02-01 14:28:55.121 🔵-[LocationManager locationManager:didChangeAuthorizationStatus:] 4

2022-02-01 14:28:55.121 🔵-[LocationManager locationManager:didChangeAuthorizationStatus:] 4

2022-02-01 14:28:55.122 🔵-[LocationManager locationManager:didChangeAuthorizationStatus:] 4

2022-02-01 14:28:55.122 ℹ️-[TSConfig persist] 

2022-02-01 14:28:55.124 🔵-[TSLocationManager locationManager:didChangeAuthorizationStatus:] status 4

2022-02-01 14:28:55.125 🔵-[BackgroundTaskManager locationManager:didChangeAuthorizationStatus:] 4

2022-02-01 14:29:06.541 
╔═══════════════════════════════════════════════════════════
║ -[TSLocationManager start] 
╚═══════════════════════════════════════════════════════════

2022-02-01 14:29:06.541 ℹ️-[TSLocationManager doStart:] trackingMode: 1

2022-02-01 14:29:06.541 ℹ️-[TSConfig persist] 

2022-02-01 14:29:06.542 🎾-[TSGeofenceManager start] 

2022-02-01 14:29:06.542 ℹ️-[TSConfig persist] 

2022-02-01 14:29:06.542 🎾-[SOMotionDetector startDetection] 

2022-02-01 14:29:06.542 🔵-[TSLocationManager setPace:] 1

2022-02-01 14:29:06.543 🎾-[TSLocationManager startUpdatingLocation] Location-services: ON

2022-02-01 14:29:06.544 
╔═══════════════════════════════════════════════════════════
║ -[TSHttpService flush:] 
╚═══════════════════════════════════════════════════════════

2022-02-01 14:29:06.544 
╔═══════════════════════════════════════════════════════════
║ -[TSHttpService finish:error:] Success: 0
╚═══════════════════════════════════════════════════════════

2022-02-01 14:29:06.544 🔵-[TSLocationManager changePace:] isMoving: 1

2022-02-01 14:29:06.544 🔵-[TSLocationManager setPace:] 1

2022-02-01 14:29:06.548 ℹ️+[LocationAuthorization run:onCancel:] status: 4

2022-02-01 14:29:06.548 🎾-[TSLocationManager startMonitoringBackgroundFetch] BackgroundFetch: ON

2022-02-01 14:29:06.551 ℹ️-[TSLocationManager startMonitoringBackgroundFetch]_block_invoke Configured BackgroundFetch

2022-02-01 14:29:06.552 🎾-[TSLocationManager startUpdatingLocation] Location-services: ON

2022-02-01 14:29:06.554 ℹ️+[LocationAuthorization run:onCancel:] status: 4

2022-02-01 14:29:06.555 
📍<+46.07072124,+8.95407510> +/- 4.60m (speed 0.00 mps / course -1.00) @ 01.02.22, 14:29:05 Central European Standard Time

2022-02-01 14:29:06.555 
╔═══════════════════════════════════════════════════════════
║ -[TSLocationManager locationManager:didUpdateLocations:] Enabled: 1 | isMoving: 1 | df: -1.0m | age: 0.6s
╚═══════════════════════════════════════════════════════════

2022-02-01 14:29:06.555 ✅-[TSLocationManager locationManager:didUpdateLocations:] Acquired motionchange position: <+46.07072124,+8.95407510> +/- 4.60m (speed 0.00 mps / course -1.00) @ 01.02.22, 14:29:05 Central European Standard Time

2022-02-01 14:29:06.555 🎾-[TSLocationManager startUpdatingLocation] Location-services: ON

2022-02-01 14:29:06.555 🔵-[TSLocationManager calculateMedianLocationAccuracy:] Median location accuracy: 4.6

2022-02-01 14:29:06.555 🎾-[TSLocationManager startMonitoringSignificantLocationChanges] 

2022-02-01 14:29:06.556 ℹ️+[LocationAuthorization run:onCancel:] status: 4

2022-02-01 14:29:06.557 ✅-[LocationDAO unlock]_block_invoke UNLOCKED ALL RECORDS

2022-02-01 14:29:06.558 ✅-[TSLocationManager persistLocation:]_block_invoke INSERT: A5A776B7-941F-431A-80A5-B5B9F73B828A

2022-02-01 14:29:06.558 
╔═══════════════════════════════════════════════════════════
║ -[TSHttpService flush:] 
╚═══════════════════════════════════════════════════════════

2022-02-01 14:29:06.558 
╔═══════════════════════════════════════════════════════════
║ -[TSHttpService finish:error:] Success: 0
╚═══════════════════════════════════════════════════════════

2022-02-01 14:29:11.540 🔵-[TSLocationManager changePace:] isMoving: 1

2022-02-01 14:29:11.540 🔵-[TSLocationManager setPace:] 1

2022-02-01 14:29:11.541 🎾-[TSLocationManager startUpdatingLocation] Location-services: ON

2022-02-01 14:29:11.543 ℹ️+[LocationAuthorization run:onCancel:] status: 4

2022-02-01 14:29:12.029 
📍<+46.07071898,+8.95407376> +/- 4.60m (speed 0.00 mps / course -1.00) @ 01.02.22, 14:29:11 Central European Standard Time

2022-02-01 14:29:12.029 
╔═══════════════════════════════════════════════════════════
║ -[TSLocationManager locationManager:didUpdateLocations:] Enabled: 1 | isMoving: 1 | df: -1.0m | age: 0.0s
╚═══════════════════════════════════════════════════════════

2022-02-01 14:29:12.029 ✅-[TSLocationManager locationManager:didUpdateLocations:] Acquired motionchange position: <+46.07071898,+8.95407376> +/- 4.60m (speed 0.00 mps / course -1.00) @ 01.02.22, 14:29:11 Central European Standard Time

2022-02-01 14:29:12.030 🎾-[TSLocationManager startUpdatingLocation] Location-services: ON

2022-02-01 14:29:12.030 🔵-[TSLocationManager calculateMedianLocationAccuracy:] Median location accuracy: 4.6

2022-02-01 14:29:12.033 ℹ️+[LocationAuthorization run:onCancel:] status: 4

2022-02-01 14:29:12.037 ✅-[TSLocationManager persistLocation:]_block_invoke INSERT: 90B7C080-DB68-4977-87D4-8944B6FC7FDA

2022-02-01 14:29:12.038 
╔═══════════════════════════════════════════════════════════
║ -[TSHttpService flush:] 
╚═══════════════════════════════════════════════════════════

2022-02-01 14:29:12.038 
╔═══════════════════════════════════════════════════════════
║ -[TSHttpService finish:error:] Success: 0
╚═══════════════════════════════════════════════════════════

2022-02-01 14:29:35.737 ✅-[SOMotionDetector startDetection]_block_invoke Enabled M7 MotionActivity updates

2022-02-01 14:29:38.736 
╔═══════════════════════════════════════════════════════════
║ -[TSLocationManager createMotionTypeChangedHandler]_block_invoke | still/33 | isMoving: 0
╚═══════════════════════════════════════════════════════════

2022-02-01 14:29:40.013 
╔═══════════════════════════════════════════════════════════
║ -[TSLocationManager createMotionTypeChangedHandler]_block_invoke | still/33 | isMoving: 0
╚═══════════════════════════════════════════════════════════

2022-02-01 14:29:42.570 
╔═══════════════════════════════════════════════════════════
║ -[TSLocationManager createMotionTypeChangedHandler]_block_invoke | still/33 | isMoving: 0
╚═══════════════════════════════════════════════════════════

2022-02-01 14:29:48.333 ✅-[BackgroundTaskManager createBackgroundTask] 5

2022-02-01 14:29:48.333 🔵-[TSLocationManager onSuspend:] enabled? 1)

2022-02-01 14:29:48.351 ℹ️-[TSDBLogger db_save] Log committed

2022-02-01 14:29:52.161 
╔═══════════════════════════════════════════════════════════
║ -[TSLocationManager createMotionTypeChangedHandler]_block_invoke | still/33 | isMoving: 0
╚═══════════════════════════════════════════════════════════

2022-02-01 14:29:56.957 
╔═══════════════════════════════════════════════════════════
║ -[TSLocationManager createMotionTypeChangedHandler]_block_invoke | still/33 | isMoving: 0
╚═══════════════════════════════════════════════════════════

2022-02-01 14:30:01.048 🔵-[BackgroundTaskManager onResume:] Current preventSuspend tasks: 1

2022-02-01 14:30:01.048 🔵-[TSLocationManager onResume:] enabled? 1

2022-02-01 14:30:01.048 ℹ️-[LocationDAO purge:] 1

2022-02-01 14:30:01.050 ℹ️-[TSDBLogger db_save] Log committed

2022-02-01 14:30:01.051 
╔═══════════════════════════════════════════════════════════
║ -[TSHttpService flush:] 
╚═══════════════════════════════════════════════════════════

2022-02-01 14:30:01.051 
╔═══════════════════════════════════════════════════════════
║ -[TSHttpService finish:error:] Success: 0
╚═══════════════════════════════════════════════════════════

2022-02-01 14:30:01.433 
╔═══════════════════════════════════════════════════════════
║ -[TSLocationManager createMotionTypeChangedHandler]_block_invoke | still/33 | isMoving: 0
╚═══════════════════════════════════════════════════════════

2022-02-01 14:30:03.011 🔵-[BackgroundTaskManager startPreventSuspendTimer:] BG time remaining: 20 | Total tasks: 1

2022-02-01 14:30:03.011 🔵-[TSLocationManager onSuspend:] enabled? 1)

2022-02-01 14:30:03.017 ℹ️-[TSDBLogger db_save] Log committed

2022-02-01 14:30:13.012 🔵-[BackgroundTaskManager onPreventSuspendTimer:] Prevent-suspend timer fired! (bg time remaining: 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000)

2022-02-01 14:30:13.016 ℹ️+[LocationAuthorization run:onCancel:] status: 4

2022-02-01 14:30:13.039 
📍<+46.07077850,+8.95395132> +/- 4.73m (speed 2.30 mps / course 305.68) @ 01.02.22, 14:30:12 Central European Standard Time

2022-02-01 14:30:13.039 
╔═══════════════════════════════════════════════════════════
║ -[TSLocationManager locationManager:didUpdateLocations:] Enabled: 1 | isMoving: 1 | df: 10.0m | age: 0.0s
╚═══════════════════════════════════════════════════════════

2022-02-01 14:30:13.039 🔵-[TSLocationManager calculateMedianLocationAccuracy:] Median location accuracy: 4.6

2022-02-01 14:30:13.039 ℹ️-[TSConfig persist] 

2022-02-01 14:30:13.041 🔵-[TSConfig incrementOdometer:] 11.5

2022-02-01 14:30:13.047 ✅-[TSLocationManager persistLocation:]_block_invoke INSERT: C9C390E1-9334-44A8-8EFF-45CE376ADEFF

2022-02-01 14:30:13.047 
╔═══════════════════════════════════════════════════════════
║ -[TSHttpService flush:] 
╚═══════════════════════════════════════════════════════════

2022-02-01 14:30:13.047 
╔═══════════════════════════════════════════════════════════
║ -[TSHttpService finish:error:] Success: 0
╚═══════════════════════════════════════════════════════════

2022-02-01 14:30:13.591 
╔═══════════════════════════════════════════════════════════
║ -[TSLocationManager createMotionTypeChangedHandler]_block_invoke | on_foot/100 | isMoving: 1
╚═══════════════════════════════════════════════════════════

2022-02-01 14:30:18.038 
📍<+46.07082746,+8.95382941> +/- 4.73m (speed 2.07 mps / course 286.67) @ 01.02.22, 14:30:17 Central European Standard Time

2022-02-01 14:30:18.038 
╔═══════════════════════════════════════════════════════════
║ -[TSLocationManager locationManager:didUpdateLocations:] Enabled: 1 | isMoving: 1 | df: 10.0m | age: 0.0s
╚═══════════════════════════════════════════════════════════

2022-02-01 14:30:18.038 🔵-[TSLocationManager calculateMedianLocationAccuracy:] Median location accuracy: 4.7

2022-02-01 14:30:18.038 ℹ️-[TSConfig persist] 

2022-02-01 14:30:18.040 🔵-[TSConfig incrementOdometer:] 22.4

2022-02-01 14:30:18.046 ✅-[TSLocationManager persistLocation:]_block_invoke INSERT: 3F94A3B2-357B-45A7-8CC4-79B4109FD615

2022-02-01 14:30:18.047 
╔═══════════════════════════════════════════════════════════
║ -[TSHttpService flush:] 
╚═══════════════════════════════════════════════════════════

2022-02-01 14:30:18.047 
╔═══════════════════════════════════════════════════════════
║ -[TSHttpService finish:error:] Success: 0
╚═══════════════════════════════════════════════════════════

2022-02-01 14:30:23.036 
📍<+46.07086882,+8.95370242> +/- 4.79m (speed 2.03 mps / course 296.12) @ 01.02.22, 14:30:22 Central European Standard Time

2022-02-01 14:30:23.036 
╔═══════════════════════════════════════════════════════════
║ -[TSLocationManager locationManager:didUpdateLocations:] Enabled: 1 | isMoving: 1 | df: 10.0m | age: 0.0s
╚═══════════════════════════════════════════════════════════

2022-02-01 14:30:23.037 🔵-[TSLocationManager calculateMedianLocationAccuracy:] Median location accuracy: 4.7

2022-02-01 14:30:23.037 ℹ️-[TSConfig persist] 

2022-02-01 14:30:23.038 🔵-[TSConfig incrementOdometer:] 33.2

2022-02-01 14:30:23.045 ✅-[TSLocationManager persistLocation:]_block_invoke INSERT: AF1D159A-FA74-4A0A-B810-E0DAAADDD9B2

2022-02-01 14:30:23.045 
╔═══════════════════════════════════════════════════════════
║ -[TSHttpService flush:] 
╚═══════════════════════════════════════════════════════════

2022-02-01 14:30:23.045 
╔═══════════════════════════════════════════════════════════
║ -[TSHttpService finish:error:] Success: 0
╚═══════════════════════════════════════════════════════════

2022-02-01 14:30:28.041 
📍<+46.07090264,+8.95357960> +/- 4.74m (speed 1.67 mps / course 297.87) @ 01.02.22, 14:30:27 Central European Standard Time

2022-02-01 14:30:28.041 
╔═══════════════════════════════════════════════════════════
║ -[TSLocationManager locationManager:didUpdateLocations:] Enabled: 1 | isMoving: 1 | df: 10.0m | age: 0.0s
╚═══════════════════════════════════════════════════════════

2022-02-01 14:30:28.041 🔵-[TSLocationManager calculateMedianLocationAccuracy:] Median location accuracy: 4.7

2022-02-01 14:30:28.041 ℹ️-[TSConfig persist] 

2022-02-01 14:30:28.043 🔵-[TSConfig incrementOdometer:] 43.5

2022-02-01 14:30:28.050 ✅-[TSLocationManager persistLocation:]_block_invoke INSERT: 9E145261-1DE3-456D-BF3C-1BCF339B3F8B

2022-02-01 14:30:28.050 
╔═══════════════════════════════════════════════════════════
║ -[TSHttpService flush:] 
╚═══════════════════════════════════════════════════════════

2022-02-01 14:30:28.050 
╔═══════════════════════════════════════════════════════════
║ -[TSHttpService finish:error:] Success: 0
╚═══════════════════════════════════════════════════════════

2022-02-01 14:30:31.491 
╔═══════════════════════════════════════════════════════════
║ -[TSLocationManager createMotionTypeChangedHandler]_block_invoke | on_foot/100 | isMoving: 1
╚═══════════════════════════════════════════════════════════

2022-02-01 14:30:33.027 
📍<+46.07091094,+8.95343743> +/- 4.75m (speed 2.09 mps / course 272.52) @ 01.02.22, 14:30:32 Central European Standard Time

2022-02-01 14:30:33.027 
╔═══════════════════════════════════════════════════════════
║ -[TSLocationManager locationManager:didUpdateLocations:] Enabled: 1 | isMoving: 1 | df: 10.0m | age: 0.0s
╚═══════════════════════════════════════════════════════════

2022-02-01 14:30:33.027 🔵-[TSLocationManager calculateMedianLocationAccuracy:] Median location accuracy: 4.7

2022-02-01 14:30:33.027 ℹ️-[TSConfig persist] 

2022-02-01 14:30:33.029 🔵-[TSConfig incrementOdometer:] 54.5

2022-02-01 14:30:33.035 ✅-[TSLocationManager persistLocation:]_block_invoke INSERT: D4F80999-C9E5-48C2-BBA3-5CF50873BD56

2022-02-01 14:30:33.035 
╔═══════════════════════════════════════════════════════════
║ -[TSHttpService flush:] 
╚═══════════════════════════════════════════════════════════

2022-02-01 14:30:33.036 
╔═══════════════════════════════════════════════════════════
║ -[TSHttpService finish:error:] Success: 0
╚═══════════════════════════════════════════════════════════

2022-02-01 14:30:34.050 
╔═══════════════════════════════════════════════════════════
║ -[TSLocationManager createMotionTypeChangedHandler]_block_invoke | on_foot/100 | isMoving: 1
╚═══════════════════════════════════════════════════════════

2022-02-01 14:30:39.038 
📍<+46.07090303,+8.95328942> +/- 4.72m (speed 1.64 mps / course 274.35) @ 01.02.22, 14:30:38 Central European Standard Time

2022-02-01 14:30:39.038 
╔═══════════════════════════════════════════════════════════
║ -[TSLocationManager locationManager:didUpdateLocations:] Enabled: 1 | isMoving: 1 | df: 10.0m | age: 0.0s
╚═══════════════════════════════════════════════════════════

2022-02-01 14:30:39.038 🔵-[TSLocationManager calculateMedianLocationAccuracy:] Median location accuracy: 4.8

2022-02-01 14:30:39.038 ℹ️-[TSConfig persist] 

2022-02-01 14:30:39.040 🔵-[TSConfig incrementOdometer:] 66.0

2022-02-01 14:30:39.047 ✅-[TSLocationManager persistLocation:]_block_invoke INSERT: 035E6304-23CD-4E10-A7D9-E948626A5742

2022-02-01 14:30:39.048 
╔═══════════════════════════════════════════════════════════
║ -[TSHttpService flush:] 
╚═══════════════════════════════════════════════════════════

2022-02-01 14:30:39.048 
╔═══════════════════════════════════════════════════════════
║ -[TSHttpService finish:error:] Success: 0
╚═══════════════════════════════════════════════════════════

2022-02-01 14:30:39.166 
╔═══════════════════════════════════════════════════════════
║ -[TSLocationManager createMotionTypeChangedHandler]_block_invoke | on_foot/100 | isMoving: 1
╚═══════════════════════════════════════════════════════════

2022-02-01 14:30:41.724 
╔═══════════════════════════════════════════════════════════
║ -[TSLocationManager createMotionTypeChangedHandler]_block_invoke | on_foot/100 | isMoving: 1
╚═══════════════════════════════════════════════════════════

2022-02-01 14:30:44.041 
📍<+46.07091775,+8.95315342> +/- 4.70m (speed 1.90 mps / course 278.12) @ 01.02.22, 14:30:43 Central European Standard Time

2022-02-01 14:30:44.041 
╔═══════════════════════════════════════════════════════════
║ -[TSLocationManager locationManager:didUpdateLocations:] Enabled: 1 | isMoving: 1 | df: 10.0m | age: 0.0s
╚═══════════════════════════════════════════════════════════

2022-02-01 14:30:44.041 🔵-[TSLocationManager calculateMedianLocationAccuracy:] Median location accuracy: 4.8

2022-02-01 14:30:44.041 ℹ️-[TSConfig persist] 

2022-02-01 14:30:44.042 🔵-[TSConfig incrementOdometer:] 76.6

2022-02-01 14:30:44.048 ✅-[TSLocationManager persistLocation:]_block_invoke INSERT: B21E3415-9C27-400B-BD3B-92DCF35D7E2C

2022-02-01 14:30:44.048 
╔═══════════════════════════════════════════════════════════
║ -[TSHttpService flush:] 
╚═══════════════════════════════════════════════════════════

2022-02-01 14:30:44.048 
╔═══════════════════════════════════════════════════════════
║ -[TSHttpService finish:error:] Success: 0
╚═══════════════════════════════════════════════════════════

2022-02-01 14:30:46.839 
╔═══════════════════════════════════════════════════════════
║ -[TSLocationManager createMotionTypeChangedHandler]_block_invoke | on_foot/100 | isMoving: 1
╚═══════════════════════════════════════════════════════════

2022-02-01 14:30:49.038 
📍<+46.07095970,+8.95303317> +/- 4.70m (speed 1.95 mps / course 298.03) @ 01.02.22, 14:30:48 Central European Standard Time

2022-02-01 14:30:49.038 
╔═══════════════════════════════════════════════════════════
║ -[TSLocationManager locationManager:didUpdateLocations:] Enabled: 1 | isMoving: 1 | df: 10.0m | age: 0.0s
╚═══════════════════════════════════════════════════════════

2022-02-01 14:30:49.038 🔵-[TSLocationManager calculateMedianLocationAccuracy:] Median location accuracy: 4.8

2022-02-01 14:30:49.038 ℹ️-[TSConfig persist] 

2022-02-01 14:30:49.041 🔵-[TSConfig incrementOdometer:] 87.0

2022-02-01 14:30:49.050 ✅-[TSLocationManager persistLocation:]_block_invoke INSERT: AEFB0B52-87B6-4A7A-A3AF-EBA2F26B08DA

2022-02-01 14:30:49.050 
╔═══════════════════════════════════════════════════════════
║ -[TSHttpService flush:] 
╚═══════════════════════════════════════════════════════════

2022-02-01 14:30:49.050 
╔═══════════════════════════════════════════════════════════
║ -[TSHttpService finish:error:] Success: 0
╚═══════════════════════════════════════════════════════════

2022-02-01 14:30:54.047 
📍<+46.07104083,+8.95297616> +/- 4.69m (speed 1.87 mps / course 339.20) @ 01.02.22, 14:30:53 Central European Standard Time

2022-02-01 14:30:54.047 
╔═══════════════════════════════════════════════════════════
║ -[TSLocationManager locationManager:didUpdateLocations:] Enabled: 1 | isMoving: 1 | df: 10.0m | age: 0.0s
╚═══════════════════════════════════════════════════════════

2022-02-01 14:30:54.047 🔵-[TSLocationManager calculateMedianLocationAccuracy:] Median location accuracy: 4.7

2022-02-01 14:30:54.047 ℹ️-[TSConfig persist] 

2022-02-01 14:30:54.049 🔵-[TSConfig incrementOdometer:] 97.1

2022-02-01 14:30:54.058 ✅-[TSLocationManager persistLocation:]_block_invoke INSERT: 3D35EFDA-0309-4BAB-848E-7DACFEA43286

2022-02-01 14:30:54.058 
╔═══════════════════════════════════════════════════════════
║ -[TSHttpService flush:] 
╚═══════════════════════════════════════════════════════════

2022-02-01 14:30:54.059 
╔═══════════════════════════════════════════════════════════
║ -[TSHttpService finish:error:] Success: 0
╚═══════════════════════════════════════════════════════════

2022-02-01 14:30:58.993 ⚠️-[BackgroundTaskManager createBackgroundTask]_block_invoke FORCE KILL BACKGROUND TASK: 5, remaining time: 2.673622

2022-02-01 14:30:58.993 ✅-[BackgroundTaskManager stopBackgroundTask:]_block_invoke 5 OF (
    5
)

2022-02-01 14:30:59.627 
╔═══════════════════════════════════════════════════════════
║ -[TSLocationManager createMotionTypeChangedHandler]_block_invoke | on_foot/100 | isMoving: 1
╚═══════════════════════════════════════════════════════════

2022-02-01 14:31:00.046 
📍<+46.07113401,+8.95290597> +/- 4.69m (speed 1.83 mps / course 338.34) @ 01.02.22, 14:30:59 Central European Standard Time

2022-02-01 14:31:00.046 
╔═══════════════════════════════════════════════════════════
║ -[TSLocationManager locationManager:didUpdateLocations:] Enabled: 1 | isMoving: 1 | df: 10.0m | age: 0.0s
╚═══════════════════════════════════════════════════════════

2022-02-01 14:31:00.046 🔵-[TSLocationManager calculateMedianLocationAccuracy:] Median location accuracy: 4.8

2022-02-01 14:31:00.046 ℹ️-[TSConfig persist] 

2022-02-01 14:31:00.047 🔵-[TSConfig incrementOdometer:] 108.8

2022-02-01 14:31:00.049 ✅-[TSLocationManager persistLocation:]_block_invoke INSERT: FC593E96-23F0-4E92-9AA4-8DCC9140C7A7

2022-02-01 14:31:00.050 
╔═══════════════════════════════════════════════════════════
║ -[TSHttpService flush:] 
╚═══════════════════════════════════════════════════════════

2022-02-01 14:31:00.050 
╔═══════════════════════════════════════════════════════════
║ -[TSHttpService finish:error:] Success: 0
╚═══════════════════════════════════════════════════════════

2022-02-01 14:44:49.630 ℹ️-[TSDBLogger db_save] Log committed

2022-02-01 14:44:49.630 ℹ️-[TSDBLogger db_delete] maxAge: 604800

2022-02-01 14:44:49.640 🔵-[TSLocationManager onResume:] enabled? 1

2022-02-01 14:44:49.650 ℹ️-[LocationDAO purge:] 1

2022-02-01 14:44:49.652 ℹ️-[TSDBLogger db_save] Log committed

2022-02-01 14:44:49.655 
╔═══════════════════════════════════════════════════════════
║ -[TSHttpService flush:] 
╚═══════════════════════════════════════════════════════════

2022-02-01 14:44:49.655 
╔═══════════════════════════════════════════════════════════
║ -[TSHttpService finish:error:] Success: 0
╚═══════════════════════════════════════════════════════════

2022-02-01 14:44:49.680 
📍<+46.07466841,+8.95057884> +/- 24.00m (speed 0.79 mps / course 13.01) @ 01.02.22, 14:44:32 Central European Standard Time

2022-02-01 14:44:49.680 
╔═══════════════════════════════════════════════════════════
║ -[TSLocationManager locationManager:didUpdateLocations:] Enabled: 1 | isMoving: 1 | df: 10.0m | age: 17.6s
╚═══════════════════════════════════════════════════════════

2022-02-01 14:44:49.680 🔵-[TSLocationManager calculateMedianLocationAccuracy:] Median location accuracy: 4.7

2022-02-01 14:44:49.680 ℹ️-[TSConfig persist] 

2022-02-01 14:44:49.681 🔵-[TSConfig incrementOdometer:] 541.0

2022-02-01 14:44:49.683 ✅-[TSLocationManager persistLocation:]_block_invoke INSERT: 0707B1AE-19FA-44B3-9C1A-5A645AD8101D

2022-02-01 14:44:49.683 
╔═══════════════════════════════════════════════════════════
║ -[TSHttpService flush:] 
╚═══════════════════════════════════════════════════════════

2022-02-01 14:44:49.683 
╔═══════════════════════════════════════════════════════════
║ -[TSHttpService finish:error:] Success: 0
╚═══════════════════════════════════════════════════════════

2022-02-01 14:44:49.710 
📍<+46.07469628,+8.95056149> +/- 4.51m (speed 0.00 mps / course -1.00) @ 01.02.22, 14:44:40 Central European Standard Time

2022-02-01 14:44:49.710 
╔═══════════════════════════════════════════════════════════
║ -[TSLocationManager locationManager:didUpdateLocations:] Enabled: 1 | isMoving: 1 | df: 10.0m | age: 8.7s
╚═══════════════════════════════════════════════════════════

2022-02-01 14:44:49.710 🔵-[TSLocationManager calculateMedianLocationAccuracy:] Median location accuracy: 4.7

2022-02-01 14:44:49.711 
📍<+46.07469628,+8.95056149> +/- 4.51m (speed 0.00 mps / course -1.00) @ 01.02.22, 14:44:49 Central European Standard Time

2022-02-01 14:44:49.711 
╔═══════════════════════════════════════════════════════════
║ -[TSLocationManager locationManager:didUpdateLocations:] Enabled: 1 | isMoving: 1 | df: 10.0m | age: 0.0s
╚═══════════════════════════════════════════════════════════

2022-02-01 14:44:49.711 🔵-[TSLocationManager calculateMedianLocationAccuracy:] Median location accuracy: 4.7

2022-02-01 14:44:49.712 ✅-[TSLocationManager persistLocation:]_block_invoke INSERT: 97DDF85A-404B-4CCD-9E6B-56818F550EA3

2022-02-01 14:44:49.712 
╔═══════════════════════════════════════════════════════════
║ -[TSHttpService flush:] 
╚═══════════════════════════════════════════════════════════

2022-02-01 14:44:49.712 
╔═══════════════════════════════════════════════════════════
║ -[TSHttpService finish:error:] Success: 0
╚═══════════════════════════════════════════════════════════

2022-02-01 14:44:49.713 ✅-[TSLocationManager persistLocation:]_block_invoke INSERT: 4111A74C-E0BC-49A4-833C-160D26632BD1

2022-02-01 14:44:49.713 
╔═══════════════════════════════════════════════════════════
║ -[TSHttpService flush:] 
╚═══════════════════════════════════════════════════════════

2022-02-01 14:44:49.713 
╔═══════════════════════════════════════════════════════════
║ -[TSHttpService finish:error:] Success: 0
╚═══════════════════════════════════════════════════════════

2022-02-01 14:44:53.384 
╔═══════════════════════════════════════════════════════════
║ -[TSLocationManager createMotionTypeChangedHandler]_block_invoke | still/33 | isMoving: 0
╚═══════════════════════════════════════════════════════════

2022-02-01 14:45:01.686 
╔═══════════════════════════════════════════════════════════
║ -[TSLocationManager createMotionTypeChangedHandler]_block_invoke | still/33 | isMoving: 0
╚═══════════════════════════════════════════════════════════

2022-02-01 14:45:05.757 ✅-[BackgroundTaskManager createBackgroundTask] 20

2022-02-01 14:45:05.757 🔵-[TSLocationManager onSuspend:] enabled? 1)

2022-02-01 14:45:05.765 ℹ️-[TSDBLogger db_save] Log committed

2022-02-01 14:45:16.129 🔵-[BackgroundTaskManager onResume:] Current preventSuspend tasks: 1

2022-02-01 14:45:16.129 🔵-[TSLocationManager onResume:] enabled? 1

2022-02-01 14:45:16.129 ℹ️-[LocationDAO purge:] 1

2022-02-01 14:45:16.131 ℹ️-[TSDBLogger db_save] Log committed

2022-02-01 14:45:16.136 
╔═══════════════════════════════════════════════════════════
║ -[TSHttpService flush:] 
╚═══════════════════════════════════════════════════════════

2022-02-01 14:45:16.136 
╔═══════════════════════════════════════════════════════════
║ -[TSHttpService finish:error:] Success: 0
╚═══════════════════════════════════════════════════════════

2022-02-01 14:45:19.932 ℹ️-[TSConfig persist] 

2022-02-01 14:45:19.933 🔵-[TSLocationManager changePace:] isMoving: 0

2022-02-01 14:45:19.933 🔵-[TSLocationManager setPace:] 0

2022-02-01 14:45:19.934 🎾-[TSLocationManager startUpdatingLocation] Location-services: ON

2022-02-01 14:45:19.934 
╔═══════════════════════════════════════════════════════════
║ -[TSLocationManager stop] 
╚═══════════════════════════════════════════════════════════

2022-02-01 14:45:19.934 ℹ️-[TSConfig persist] 

2022-02-01 14:45:19.935 ℹ️+[LocationAuthorization run:onCancel:] status: 4

2022-02-01 14:45:19.935 ℹ️-[TSLocationManager clearLastOdometerLocation] 

2022-02-01 14:45:19.935 🔴-[TSGeofenceManager stop] 

2022-02-01 14:45:19.935 🔴-[TSGeofenceManager stopMonitoringGeofences] 

2022-02-01 14:45:19.936 🔴-[SOMotionDetector stopDetection] OFF

2022-02-01 14:45:19.936 🔴-[TSLocationManager stopUpdatingLocation] 

2022-02-01 14:45:19.936 🔴-[TSLocationManager stopMonitoringBackgroundFetch] BackgroundFetch: OFF

2022-02-01 14:45:19.937 🔴-[TSLocationManager stopMonitoringSignificantLocationChanges] 

2022-02-01 14:45:32.531 ℹ️-[TSDBLogger db_save] Log committed

ironmanromeo avatar Feb 02 '22 12:02 ironmanromeo

We are having the same issue since iOS update 15.1+ See my comment here : https://github.com/transistorsoft/react-native-background-geolocation/issues/1455 Also tried setting the "changePace(true)" and same happens

ghost avatar Mar 03 '22 11:03 ghost

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 May 02 '22 11:05 stale[bot]

My proposal is to change desiredAccuracy to DESIRED_ACCURACY_HIGH. It is pretty good for all cases and consumes significantly less energy on iPhones (checked with an app written in swift). Here are my settings for iOS and it works pretty well. I can record for many hours without killing location service by OS.

          stopOnTerminate: false, // not necessary for When in use permission
          desiredAccuracy: BackgroundGeolocation.DESIRED_ACCURACY_HIGH,
          distanceFilter: 10, // this can be customized according to your needs
          stopTimeout:  isIOS ? 30 : 15,
          desiredOdometerAccuracy: 60, // this can be customized according to your needs
          preventSuspend: true,
          heartbeatInterval: 60,
          activityType: BackgroundGeolocation.ACTIVITY_TYPE_FITNESS,
          pausesLocationUpdatesAutomatically: false,
          disableStopDetection: true, // this is quite important
            

What I do to start service is .start() and .changePace(true). Location permission on a device is When in use. With such settings, I have no issues. Tested on iPhone 8 & iPhone 12 (the app is on the market).

Speaking about Android devices remember that your app HAS TO BE added to exceptions in the energy manager on your device.

I hope it will help you.

And here is a link to documentation that describes how to keep location services online on iOS

likrot avatar Aug 23 '22 15:08 likrot

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]