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

iOS stop tracking when you close the application

Open tofoli opened this issue 7 years ago • 4 comments

Your Environment

  • Plugin version: 3.0.0-beta.4
  • Platform: iOS
  • OS version: 11.4
  • Device manufacturer / model: iPhone 6 64GB MG3H2BR/A
  • React Native version (react-native -v): react-native-cli: 2.0.1 react-native: 0.57.8
  • Plugin config
{
   activityRecognitionInterval = 10000;
   activityType = 1;
   autoSync = 1;
   autoSyncThreshold = 0;
   batchSync = 1;
   debug = 0;
   desiredAccuracy = "-1";
   desiredOdometerAccuracy = 100;
   disableElasticity = 0;
   disableLocationAuthorizationAlert = 1;
   disableMotionActivityUpdates = 0;
   disableStopDetection = 0;
   distanceFilter = 10;
   elasticityMultiplier = 1;
   enabled = 1;
   extras =    {
   };
   geofenceInitialTriggerEntry = 1;
   geofenceProximityRadius = 1000;
   geofenceTemplate = "";
   headers =    {
       Accept = "application/json";
       "Accept-Language" = "pt-BR";
       Authorization = "Bearer ****";
       "Content-Type" = "application/json";
   };
   heartbeatInterval = 60;
   httpRootProperty = location;
   httpTimeout = 60000;
   iOSHasWarnedLocationServicesOff = 0;
   isFirstBoot = 0;
   isMoving = 0;
   lastLocationAuthorizationStatus = 3;
   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 = Always;
   locationTemplate = "{\"lat\":<%= latitude %>,\"lon\":<%= longitude %>,\"acc\":<%= accuracy %>,\"b_charging\":<%= battery.is_charging %>,\"b_level\":<%= battery.level %>,\"a_type\":\"<%= activity.type %>\",\"a_confidence\":<%= activity.confidence %>,\"time\":\"<%= timestamp %>\"}";
   locationTimeout = 60;
   locationsOrderDirection = DESC;
   logLevel = 4;
   logMaxDays = 3;
   maxBatchSize = 50;
   maxDaysToPersist = 30;
   maxRecordsToPersist = "-1";
   method = POST;
   minimumActivityRecognitionConfidence = 70;
   odometer = 0;
   params =    {
   };
   pausesLocationUpdatesAutomatically = 0;
   persistMode = 2;
   preventSuspend = 0;
   schedule =    (
   );
   schedulerEnabled = 0;
   startOnBoot = 1;
   stationaryRadius = 30;
   stopAfterElapsedMinutes = "-1";
   stopDetectionDelay = 0;
   stopOnStationary = 0;
   stopOnTerminate = 0;
   stopTimeout = 5;
   trackingMode = 1;
   url = "****/api/v1/geolocations";
   useSignificantChangesOnly = 0;
}

Expected Behavior

Track and forward locations to the configured URL, even with the application closed

Actual Behavior

Stop tracking when the app is closed

Steps to Reproduce

  1. Close the application
  2. View the blank log

Context

Trace and forward the locations to the configured URL, even with the application closed. For comparison, I went out and made a vehicle route from ~12:06 to 12:16, so I stopped until I made another vehicle route from ~1:15 p.m. to 1:30 p.m. with an Android device and another iOS in my pocket.

Debug logs

ios-background-geolocation.log android-background-geolocation.log

Here is the android configuration

tofoli avatar Mar 26 '19 17:03 tofoli

Why are you showing me Android config / logs if this is an iOS issue?

christocracy avatar Mar 26 '19 19:03 christocracy

Do you understand the iOS section of stopOnTerminate doc?

christocracy avatar Mar 26 '19 19:03 christocracy

I put the Android files for comparison because the two devices did the same routes. I walked much more than 200 meters. It was about 5 km, 12 minutes in a vehicle

If you compare the Android log files with iOS, you'll see that Android ran several readings, from 12:06 am to 12:16 and 1:15 pm at 1:30 pm, while iOS did not write anything in log.

You can read the Android log and with coordinates see the route and the distance covered

tofoli avatar Mar 26 '19 20:03 tofoli

Hi @christocracy

I found the problem, it's unrelated to your library, it's related to the realm-js library #2349

I'm sorry for stealing your time!

tofoli avatar Apr 23 '19 14:04 tofoli