react-native-background-geolocation
react-native-background-geolocation copied to clipboard
IOS >16 no location events with app closed
Your Environment
- Plugin version: 4.17.1
- Platform: iOS
- OS version: 16.7.10
- Device manufacturer / model: Iphone 8
- React Native version (
react-native -v): 0.74.1 - Plugin config
await BackgroundGeolocation.ready({
// Geolocation Config
stationaryRadius: 0, // The minimum distance the device must move beyond the stationary
// location for aggressive background-tracking to engage.
// Note: iOS will not detect the exact moment the device moves out of the stationary-radius. In normal conditions, it will typically
//take ~200 meters of movement before the plugin begins tracking.
stopOnStationary: false, // Automatically BackgroundGeolocation.stop when the stopTimeout elapses.
enableHeadless: true, // This is required to allow us to do some logging when location events occurs
// When set to false the location is still sent to the backend but the
// js callbacks are not executed.
desiredAccuracy: BackgroundGeolocation.DESIRED_ACCURACY_HIGH,
distanceFilter: 10,
stopTimeout: 10, // The number of minutes to wait before turning off location-services (activity Recognition)
// Application config
debug: true, // <-- enable this hear sounds for background-geolocation life-cycle.
logLevel: BackgroundGeolocation.LOG_LEVEL_INFO,
//preventSuspend: true, //TODO
// Android & iOS location-services will never turn off
disableStopDetection: true,
pausesLocationUpdatesAutomatically: false, // Need for iOS to set location-services will never turn off along with disableStopDetection
stopOnTerminate: false, // <-- Allow the background-service to continue tracking when user closes the app.
startOnBoot: true, // <-- Auto start tracking when device is powered-up.
isMoving: true, // Consider the initial state as moving
url: ${baseUrl}gamification/scenario/set-location-and-activity,
batchSync: false, // <-- [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.
headers: { // <-- Optional HTTP headers
"Content-Type": "application/json",
"X-Morfin-Custom-Routing": DEV_ROUTES,
"Authorization": ${globalUser.identity.token_type} ${globalUser.identity.access_token},
"X-Morfin-Client": getHeaderVersion()
},
disableLocationAuthorizationAlert: false,
locationAuthorizationRequest: "Any", // Alow our code to handle the authorization request
backgroundPermissionRationale: {
message: I18n.t("request_permissions_bk_location"),
negativeAction: I18n.t("no_label"),
positiveAction: I18n.t("yes_label")
},
locationTemplate: '{"latitude":<%= latitude %>,"longitude":<%= longitude %>, "activity": "<%= activity.type %>", "timestamp": "<%= timestamp %>", "speed": <%= speed %>, "speed_accuracy": <%= speed_accuracy %>, "heading": <%= heading %>, "accuracy": <%= accuracy %>, "altitude": <%= altitude %>, "altitude_accuracy": <%= altitude_accuracy %>, "uuid": "<%= uuid %>", "event": "<%= event %>", "odometer": <%= odometer %>, "activity_confidence": <%= activity.confidence %>, "battery_level": <%= battery.level %>, "battery_is_charging": <%= battery.is_charging %>, "mock": <%= mock %>, "is_moving": <%= is_moving %>}',
httpRootProperty: ".",
notification: {
smallIcon: "mipmap/ic_notification",
color: "#02d1bb",
channelId: TRACKING_CHANNEL_ID,
channelName: I18n.t('mining_title')
}
});
Expected Behavior
Receive background location events after the app is closed.
Actual Behavior
When the app is closed, the location icon disappears almost instantly and no other locations are sent until the application is reopened.
Steps to Reproduce
- Start the background location service
- Close app normally
- Start moving
Context
We have noticed that ever since IOS 16 the number of locations we receive reduced drastically. We have tried different configurations to make it more aggressive and still cannot figure out a solution.
Debug logs
Logs
2024-09-18 13:44:09.994 đĩ-[TSLocationManager ready]
2024-09-18 13:44:10.015 âšī¸-[TSLocationManager doStart:] trackingMode: 1
2024-09-18 13:44:10.016 đž-[TSGeofenceManager start]
2024-09-18 13:44:10.017 đž-[SOMotionDetector startDetection]
2024-09-18 13:44:10.018 đĩ-[TSLocationManager setPace:] 1
2024-09-18 13:44:10.021 đž-[TSLocationManager startUpdatingLocation] Location-services: ON
2024-09-18 13:44:10.036 âšī¸+[LocationAuthorization run:onCancel:] status: 3
2024-09-18 13:44:10.038 đž-[TSLocationManager startMonitoringBackgroundFetch] BackgroundFetch: ON
2024-09-18 13:44:10.046 âšī¸-[TSLocationManager locationManager:didUpdateLocations:] Received stale motionchange location. Retrying...
2024-09-18 13:44:10.055 âšī¸-[TSLocationManager locationManager:didUpdateLocations:] Received stale motionchange location. Retrying...
2024-09-18 13:44:10.103 â
-[TSLocationManager locationManager:didUpdateLocations:] Acquired motionchange position: <+45.67359217,+25.62389736> +/- 11.70m (speed -1.00 mps / course -1.00) @ 18.09.2024, 13:44:10 Eastern European Summer Time
2024-09-18 13:44:10.104 đž-[TSLocationManager startUpdatingLocation] Location-services: ON
2024-09-18 13:44:10.105 đĩ-[TSLocationManager calculateMedianLocationAccuracy:] Median location accuracy: 11.7
2024-09-18 13:44:10.106 đž-[TSLocationManager startMonitoringSignificantLocationChanges]
2024-09-18 13:44:10.110 âšī¸+[LocationAuthorization run:onCancel:] status: 3
2024-09-18 13:44:10.113 â
-[TSLocationManager persistLocation:]_block_invoke INSERT: 0C63BBEC-69C1-48A0-B2BB-BFA3FA7A4B5B
2024-09-18 13:44:10.173 â
-[BackgroundTaskManager createBackgroundTask] 28
2024-09-18 13:44:10.175 â
-[TSHttpService schedulePost] LOCKED: 0C63BBEC-69C1-48A0-B2BB-BFA3FA7A4B5B
2024-09-18 13:44:10.326 đĩ-[HttpResponse handleResponse] Response: 200
2024-09-18 13:44:10.329 â
-[TSHttpService post:]_block_invoke DESTROY: 0C63BBEC-69C1-48A0-B2BB-BFA3FA7A4B5B
2024-09-18 13:44:10.330 â
-[BackgroundTaskManager stopBackgroundTask:]_block_invoke 28 OF (
28
)
2024-09-18 13:44:11.584 â
-[SOMotionDetector startDetection]_block_invoke Enabled M7 MotionActivity updates
2024-09-18 13:44:12.113 đĩ-[TSLocationManager getCurrentPosition:]
2024-09-18 13:44:12.113 đž-[LocationManager startUpdatingLocation] ON
2024-09-18 13:44:12.117 âšī¸+[LocationAuthorization run:onCancel:] status: 3
2024-09-18 13:44:12.117 đ´-[LocationManager stopUpdatingLocation] OFF
2024-09-18 13:44:12.118 đĩ-[TSLocationManager calculateMedianLocationAccuracy:] Median location accuracy: 11.7
2024-09-18 13:44:12.125 â
-[TSLocationManager persistLocation:]_block_invoke INSERT: 557AA1F2-BC16-4D93-9231-AA08B85A4D74
2024-09-18 13:44:12.128 â
-[BackgroundTaskManager createBackgroundTask] 35
2024-09-18 13:44:12.129 â
-[TSHttpService schedulePost] LOCKED: 557AA1F2-BC16-4D93-9231-AA08B85A4D74
2024-09-18 13:44:12.263 đĩ-[HttpResponse handleResponse] Response: 200
2024-09-18 13:44:12.269 â
-[TSHttpService post:]_block_invoke DESTROY: 557AA1F2-BC16-4D93-9231-AA08B85A4D74
2024-09-18 13:44:12.269 â
-[BackgroundTaskManager stopBackgroundTask:]_block_invoke 35 OF (
35
)
2024-09-18 13:44:17.129 đĩ-[TSLocationManager getCurrentPosition:]
2024-09-18 13:44:17.129 đž-[LocationManager startUpdatingLocation] ON
2024-09-18 13:44:17.136 âšī¸+[LocationAuthorization run:onCancel:] status: 3
2024-09-18 13:44:17.136 đ´-[LocationManager stopUpdatingLocation] OFF
2024-09-18 13:44:17.136 đĩ-[TSLocationManager calculateMedianLocationAccuracy:] Median location accuracy: 11.7
2024-09-18 13:44:17.145 â
-[TSLocationManager persistLocation:]_block_invoke INSERT: 84BA7B57-E4B4-442B-A0DE-6B12B2432D52
2024-09-18 13:44:17.147 â
-[BackgroundTaskManager createBackgroundTask] 42
2024-09-18 13:44:17.150 â
-[TSHttpService schedulePost] LOCKED: 84BA7B57-E4B4-442B-A0DE-6B12B2432D52
2024-09-18 13:44:17.292 đĩ-[HttpResponse handleResponse] Response: 200
2024-09-18 13:44:17.299 â
-[TSHttpService post:]_block_invoke DESTROY: 84BA7B57-E4B4-442B-A0DE-6B12B2432D52
2024-09-18 13:44:17.300 â
-[BackgroundTaskManager stopBackgroundTask:]_block_invoke 42 OF (
42
)
2024-09-18 13:44:21.688 đĩ-[TSLocationManager getCurrentPosition:]
2024-09-18 13:44:21.688 đž-[LocationManager startUpdatingLocation] ON
2024-09-18 13:44:21.692 âšī¸+[LocationAuthorization run:onCancel:] status: 3
2024-09-18 13:44:21.692 đ´-[LocationManager stopUpdatingLocation] OFF
2024-09-18 13:44:21.696 â
-[TSLocationManager persistLocation:]_block_invoke INSERT: D45AB550-7E03-4E39-B78A-C2F2C4CE515D
2024-09-18 13:44:21.699 â
-[BackgroundTaskManager createBackgroundTask] 55
2024-09-18 13:44:21.702 â
-[TSHttpService schedulePost] LOCKED: D45AB550-7E03-4E39-B78A-C2F2C4CE515D
2024-09-18 13:44:21.844 đĩ-[HttpResponse handleResponse] Response: 200
2024-09-18 13:44:21.847 â
-[TSHttpService post:]_block_invoke DESTROY: D45AB550-7E03-4E39-B78A-C2F2C4CE515D
2024-09-18 13:44:21.847 â
-[BackgroundTaskManager stopBackgroundTask:]_block_invoke 55 OF (
55
)
2024-09-18 13:44:28.852 đĩ-[TSLocationManager onSuspend:] enabled? 1)
2024-09-18 13:45:40.278 đĩ-[TSLocationManager locationManager:didChangeAuthorizationStatus:] status 3
2024-09-18 13:45:40.283 đĩ-[LocationManager locationManager:didChangeAuthorizationStatus:] 3
2024-09-18 13:45:40.283 đĩ-[PolygonGeofencingService locationManager:didChangeAuthorizationStatus:] 3
2024-09-18 13:45:40.283 đĩ-[LocationManager locationManager:didChangeAuthorizationStatus:] 3
2024-09-18 13:45:40.283 đĩ-[BackgroundTaskManager locationManager:didChangeAuthorizationStatus:] 3
2024-09-18 13:45:40.283 đĩ-[LocationManager locationManager:didChangeAuthorizationStatus:] 3
2024-09-18 13:45:40.295 âšī¸+[LocationAuthorization run:onCancel:] status: 3
2024-09-18 13:45:41.932 âšī¸-[TSLocationManager log:message:] [RNBackgroundGeolocation startObserving]
2024-09-18 13:45:42.223 âšī¸-[TSLocationManager on:success:failure:] location
2024-09-18 13:45:42.223 âšī¸-[TSLocationManager on:success:failure:] motionchange
2024-09-18 13:45:42.223 âšī¸-[TSLocationManager on:success:failure:] activitychange
2024-09-18 13:45:42.223 âšī¸-[TSLocationManager on:success:failure:] heartbeat
2024-09-18 13:45:42.223 âšī¸-[TSGeofenceManager onGeofence:]
2024-09-18 13:45:42.223 âšī¸-[TSGeofenceManager onGeofencesChange:]
2024-09-18 13:45:42.223 âšī¸-[TSLocationManager on:success:failure:] http
2024-09-18 13:45:42.223 âšī¸-[TSLocationManager on:success:failure:] providerchange
2024-09-18 13:45:42.223 âšī¸-[TSLocationManager on:success:failure:] schedule
2024-09-18 13:45:42.223 âšī¸-[TSLocationManager on:success:failure:] powersavechange
2024-09-18 13:45:42.224 âšī¸-[TSHttpService onConnectivityChange:]
2024-09-18 13:45:42.224 âšī¸-[TSLocationManager on:success:failure:] enabledchange
2024-09-18 13:45:42.224 âšī¸-[TSHttpService onAuthorization:]
2024-09-18 13:45:42.239 đĩ-[TSLocationManager ready]
2024-09-18 13:45:42.241 âšī¸-[TSLocationManager doStart:] trackingMode: 1
2024-09-18 13:45:42.241 đž-[TSGeofenceManager start]
2024-09-18 13:45:42.242 đž-[SOMotionDetector startDetection]
2024-09-18 13:45:42.242 đĩ-[TSLocationManager setPace:] 1
2024-09-18 13:45:42.245 đž-[TSLocationManager startUpdatingLocation] Location-services: ON
2024-09-18 13:45:42.248 â
-[LocationDAO unlock]_block_invoke UNLOCKED ALL RECORDS
2024-09-18 13:45:42.255 âšī¸+[LocationAuthorization run:onCancel:] status: 3
2024-09-18 13:45:42.256 đž-[TSLocationManager startMonitoringBackgroundFetch] BackgroundFetch: ON
2024-09-18 13:45:42.257 â ī¸-[TSLocationManager start] Already started (ignored)
2024-09-18 13:45:42.270 â
-[SOMotionDetector startDetection]_block_invoke Enabled M7 MotionActivity updates
2024-09-18 13:45:42.273 âšī¸-[TSLocationManager locationManager:didUpdateLocations:] Received stale motionchange location. Retrying...
2024-09-18 13:45:42.274 â
-[TSLocationManager locationManager:didUpdateLocations:] Acquired motionchange position: <+45.67359217,+25.62389736> +/- 11.70m (speed -1.00 mps / course -1.00) @ 18.09.2024, 13:45:42 Eastern European Summer Time
2024-09-18 13:45:42.274 đž-[TSLocationManager startUpdatingLocation] Location-services: ON
2024-09-18 13:45:42.274 đĩ-[TSLocationManager calculateMedianLocationAccuracy:] Median location accuracy: 11.7
2024-09-18 13:45:42.275 đž-[TSLocationManager startMonitoringSignificantLocationChanges]
2024-09-18 13:45:42.277 âšī¸+[LocationAuthorization run:onCancel:] status: 3
2024-09-18 13:45:42.279 â
-[TSLocationManager persistLocation:]_block_invoke INSERT: 6FBA5D79-2D45-4346-971A-7200DE2F5771
2024-09-18 13:45:42.282 â
-[BackgroundTaskManager createBackgroundTask] 7
2024-09-18 13:45:42.285 â
-[TSHttpService schedulePost] LOCKED: 6FBA5D79-2D45-4346-971A-7200DE2F5771
2024-09-18 13:45:42.479 đĩ-[HttpResponse handleResponse] Response: 200
2024-09-18 13:45:42.486 â
-[TSHttpService post:]_block_invoke DESTROY: 6FBA5D79-2D45-4346-971A-7200DE2F5771
2024-09-18 13:45:42.486 â
-[BackgroundTaskManager stopBackgroundTask:]_block_invoke 7 OF (
7
)