-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Why can't I use BLE Central in the background on iOS? #300
Comments
You can do anything you want while the plug-in is in the moving state. Read the wiki “Philosophy of Operation” to learn about the plug-ins two states: stationary and moving. |
Why does the event not work in the terminated state? BackgroundGeolocation.onLocation( 2024-12-21 16:31:49.926 🔵-[TSLocationManager calculateMedianLocationAccuracy:] Median location accuracy: 5.0 2024-12-21 16:31:49.926 ℹ️-[TSConfig persist] 2024-12-21 16:31:49.929 🔵-[TSConfig incrementOdometer:] 6319.8 2024-12-21 16:31:49.938 ✅-[TSLocationManager persistLocation:]_block_invoke INSERT: EF699C38-BE54-42CC-A10A-D4F0E7A8175C 2024-12-21 16:31:55.602 🔵-[TSLocationManager calculateMedianLocationAccuracy:] Median location accuracy: 5.0 2024-12-21 16:31:55.602 ℹ️-[TSConfig persist] 2024-12-21 16:31:55.605 🔵-[TSConfig incrementOdometer:] 6409.5 2024-12-21 16:31:55.616 ✅-[TSLocationManager persistLocation:]_block_invoke INSERT: B74B52E7-A13E-4F6A-8542-295AE2DC2721 2024-12-21 16:31:55.951 🔵-[TSLocationManager createMotionTypeChangedHandler]_block_invoke Shake count: 0 2024-12-21 16:31:55.952 🔵-[TSLocationManager startMotionTriggerTimer] Motion-trigger timer engaged: Stop-detection will trigger in 10 seconds... 2024-12-21 16:31:59.869 🔵-[TSLocationManager calculateMedianLocationAccuracy:] Median location accuracy: 5.0 2024-12-21 16:31:59.869 ℹ️-[TSConfig persist] 2024-12-21 16:31:59.872 🔵-[TSConfig incrementOdometer:] 6497.6 2024-12-21 16:31:59.883 ✅-[TSLocationManager persistLocation:]_block_invoke INSERT: 664EB9F2-7C2A-48A1-B31E-D1AE80E4928F 2024-12-21 16:32:04.867 🔵-[TSLocationManager calculateMedianLocationAccuracy:] Median location accuracy: 5.0 2024-12-21 16:32:04.867 ℹ️-[TSConfig persist] 2024-12-21 16:32:04.870 🔵-[TSConfig incrementOdometer:] 6584.4 2024-12-21 16:32:04.879 ✅-[TSLocationManager persistLocation:]_block_invoke INSERT: 3AFB378B-EE20-44E9-AC84-FD86DC912DF0 2024-12-21 16:32:05.953 🔵-[TSLocationManager beginStopDetection] ⏲Stop-timeout engaged: 300 s... 2024-12-21 16:32:06.951 🔵-[TSLocationManager createMotionTypeChangedHandler]_block_invoke Shake count: 0 2024-12-21 16:32:17.951 🔵-[TSLocationManager createMotionTypeChangedHandler]_block_invoke Shake count: 0 2024-12-21 16:32:28.949 🔵-[TSLocationManager createMotionTypeChangedHandler]_block_invoke Shake count: 0 2024-12-21 16:32:39.951 🔵-[TSLocationManager createMotionTypeChangedHandler]_block_invoke Shake count: 0 2024-12-21 16:32:40.792 🔵-[TSLocationManager locationManager:didUpdateLocations:] stoppedAt is set. Bailing out 2024-12-21 16:32:50.950 🔵-[TSLocationManager createMotionTypeChangedHandler]_block_invoke Shake count: 0 2024-12-21 16:33:01.948 🔵-[TSLocationManager createMotionTypeChangedHandler]_block_invoke Shake count: 0 2024-12-21 16:33:12.947 🔵-[TSLocationManager createMotionTypeChangedHandler]_block_invoke Shake count: 0 2024-12-21 16:33:23.951 🔵-[TSLocationManager createMotionTypeChangedHandler]_block_invoke Shake count: 0 2024-12-21 16:33:34.950 🔵-[TSLocationManager createMotionTypeChangedHandler]_block_invoke Shake count: 0 2024-12-21 16:33:45.951 🔵-[TSLocationManager createMotionTypeChangedHandler]_block_invoke Shake count: 0 2024-12-21 16:33:56.949 🔵-[TSLocationManager createMotionTypeChangedHandler]_block_invoke Shake count: 0 2024-12-21 16:34:07.946 🔵-[TSLocationManager createMotionTypeChangedHandler]_block_invoke Shake count: 0 2024-12-21 16:34:18.951 🔵-[TSLocationManager createMotionTypeChangedHandler]_block_invoke Shake count: 0 2024-12-21 16:34:29.951 🔵-[TSLocationManager createMotionTypeChangedHandler]_block_invoke Shake count: 0 2024-12-21 16:34:40.950 🔵-[TSLocationManager createMotionTypeChangedHandler]_block_invoke Shake count: 0 2024-12-21 16:34:51.950 🔵-[TSLocationManager createMotionTypeChangedHandler]_block_invoke Shake count: 0 2024-12-21 16:35:02.950 🔵-[TSLocationManager createMotionTypeChangedHandler]_block_invoke Shake count: 0 2024-12-21 16:35:13.948 🔵-[TSLocationManager createMotionTypeChangedHandler]_block_invoke Shake count: 0 2024-12-21 16:35:24.946 🔵-[TSLocationManager createMotionTypeChangedHandler]_block_invoke Shake count: 0 2024-12-21 16:35:35.950 🔵-[TSLocationManager createMotionTypeChangedHandler]_block_invoke Shake count: 0 2024-12-21 16:35:43.931 🔵-[TSLocationManager locationManager:didUpdateLocations:] stoppedAt is set. Bailing out 2024-12-21 16:35:46.950 🔵-[TSLocationManager createMotionTypeChangedHandler]_block_invoke Shake count: 0 2024-12-21 16:35:57.948 🔵-[TSLocationManager createMotionTypeChangedHandler]_block_invoke Shake count: 0 2024-12-21 16:36:08.950 🔵-[TSLocationManager createMotionTypeChangedHandler]_block_invoke Shake count: 0 2024-12-21 16:36:19.950 🔵-[TSLocationManager createMotionTypeChangedHandler]_block_invoke Shake count: 0 2024-12-21 16:36:30.949 🔵-[TSLocationManager createMotionTypeChangedHandler]_block_invoke Shake count: 0 2024-12-21 16:36:41.949 🔵-[TSLocationManager createMotionTypeChangedHandler]_block_invoke Shake count: 0 2024-12-21 16:36:52.946 🔵-[TSLocationManager createMotionTypeChangedHandler]_block_invoke Shake count: 0 2024-12-21 16:37:03.945 🔵-[TSLocationManager createMotionTypeChangedHandler]_block_invoke Shake count: 0 2024-12-21 16:37:05.957 🔵-[TSLocationManager onStopTimeout:] stopTimer fired 2024-12-21 16:37:05.957 🔵-[TSLocationManager setPace:] 0 2024-12-21 16:37:05.958 ℹ️-[TSConfig persist] 2024-12-21 16:37:05.963 🔴-[SOMotionDetector stopShakeDetection] OFF 2024-12-21 16:37:05.964 🎾-[TSLocationManager startUpdatingLocation] Location-services: ON 2024-12-21 16:37:05.965 🎾-[TSLocationManager startMonitoringSignificantLocationChanges] 2024-12-21 16:37:05.965 ℹ️-[TSLocationManager resetStopTimeoutTimer] 2024-12-21 16:37:05.987 ℹ️+[LocationAuthorization run:onCancel:] status: 3 2024-12-21 16:37:05.988 ✅-[TSLocationManager locationManager:didUpdateLocations:] Acquired motionchange position: <+10.84317400,+106.64172400> +/- 5.00m (speed -1.00 mps / course -1.00) @ 12/21/24, 16:37:05 Indochina Time 2024-12-21 16:37:05.988 ℹ️-[TSConfig persist] 2024-12-21 16:37:05.990 🔵-[TSConfig incrementOdometer:] 11558.4 2024-12-21 16:37:05.990 🔵-[TSLocationManager startMonitoringStationaryRegion:radius:] Radius: 200 2024-12-21 16:37:05.991 🔵-[TSLocationManager beginHeartbeat] 60 2024-12-21 16:37:05.991 🎾-[SOMotionDetector startShakeDetection:] sample-rate: 1.0 | M7 DISABLED 2024-12-21 16:37:05.991 🔴-[TSLocationManager stopUpdatingLocation] 2024-12-21 16:37:05.991 🔵-[TSLocationManager calculateMedianLocationAccuracy:] Median location accuracy: 5.0 2024-12-21 16:37:05.995 ✅-[BackgroundTaskManager createBackgroundTask] 99 2024-12-21 16:37:06.001 ✅-[TSLocationManager persistLocation:]_block_invoke INSERT: D591FDC3-FF14-442B-9F51-F2E7ACE0A05F 2024-12-21 16:37:06.003 ✅-[BackgroundTaskManager createBackgroundTask] 100 2024-12-21 16:37:06.006 🔵-[LocationDAO allWithLocking:]_block_invoke LOCKED 5 RECORDS 2024-12-21 16:37:06.006 🔵-[TSHttpService postBatch:] 5 records 2024-12-21 16:37:06.956 🔵-[HttpResponse handleResponse] Response: 200 2024-12-21 16:37:06.956 ✅-[LocationDAO destroyAll:] DESTROY: EF699C38-BE54-42CC-A10A-D4F0E7A8175C 2024-12-21 16:37:06.956 ✅-[LocationDAO destroyAll:] DESTROY: B74B52E7-A13E-4F6A-8542-295AE2DC2721 2024-12-21 16:37:06.957 ✅-[LocationDAO destroyAll:] DESTROY: 664EB9F2-7C2A-48A1-B31E-D1AE80E4928F 2024-12-21 16:37:06.957 ✅-[LocationDAO destroyAll:] DESTROY: 3AFB378B-EE20-44E9-AC84-FD86DC912DF0 2024-12-21 16:37:06.957 ✅-[LocationDAO destroyAll:] DESTROY: D591FDC3-FF14-442B-9F51-F2E7ACE0A05F 2024-12-21 16:37:06.967 ✅-[LocationDAO destroyAll:]_block_invoke DESTROY SUCCESS (5) 2024-12-21 16:37:06.968 🔵-[LocationDAO allWithLocking:]_block_invoke LOCKED 0 RECORDS 2024-12-21 16:37:06.968 ✅-[BackgroundTaskManager stopBackgroundTask:]_block_invoke 100 OF ( 2024-12-21 16:37:09.001 🔵-[BackgroundTaskManager startPreventSuspendTimer:] BG time remaining: 28 | Total tasks: 1 2024-12-21 16:37:17.086 🔵-[TSLocationManager createMotionTypeChangedHandler]_block_invoke Shake count: 0 2024-12-21 16:37:17.086 🔴-[SOMotionDetector stopShakeDetection] OFF 2024-12-21 16:37:17.087 🎾-[SOMotionDetector startShakeDetection:] sample-rate: 1.0 | M7 DISABLED 2024-12-21 16:37:27.253 🔵-[BackgroundTaskManager onPreventSuspendTimer:] Prevent-suspend timer fired! (bg time remaining: 9.911805) 2024-12-21 16:37:27.275 ℹ️+[LocationAuthorization run:onCancel:] status: 3 2024-12-21 16:37:28.119 🔵-[TSLocationManager createMotionTypeChangedHandler]_block_invoke Shake count: 0 2024-12-21 16:37:28.119 🔴-[SOMotionDetector stopShakeDetection] OFF 2024-12-21 16:37:28.120 🎾-[SOMotionDetector startShakeDetection:] sample-rate: 1.0 | M7 DISABLED 2024-12-21 16:37:30.282 🔵-[BackgroundTaskManager startPreventSuspendTimer:] BG time remaining: 28 | Total tasks: 1 2024-12-21 16:37:30.922 🔵-[TSLocationManager locationManager:didExitRegion:] Exit stationary region 2024-12-21 16:37:30.922 🔵-[TSLocationManager setPace:] 1 2024-12-21 16:37:30.922 ℹ️-[TSConfig persist] 2024-12-21 16:37:30.926 🔴-[SOMotionDetector stopShakeDetection] OFF 2024-12-21 16:37:30.927 🔴-[TSLocationManager stopHeartbeat] 2024-12-21 16:37:30.927 🎾-[SOMotionDetector startShakeDetection:] sample-rate: 0.2 | M7 DISABLED 2024-12-21 16:37:30.931 🎾-[TSLocationManager startUpdatingLocation] Location-services: ON 2024-12-21 16:37:30.931 🎾-[TSLocationManager startMonitoringSignificantLocationChanges] 2024-12-21 16:37:30.932 ✅-[BackgroundTaskManager stopBackgroundTask:]_block_invoke 99 OF ( 2024-12-21 16:37:30.937 ℹ️+[LocationAuthorization run:onCancel:] status: 3 2024-12-21 16:37:30.958 ✅-[TSLocationManager locationManager:didUpdateLocations:] Acquired motionchange position: <+10.84091500,+106.64506600> +/- 5.00m (speed -1.00 mps / course -1.00) @ 12/21/24, 16:37:30 Indochina Time 2024-12-21 16:37:30.958 🎾-[TSLocationManager startUpdatingLocation] Location-services: ON 2024-12-21 16:37:30.959 🎾-[TSLocationManager startMonitoringSignificantLocationChanges] 2024-12-21 16:37:30.960 🔵-[TSLocationManager calculateMedianLocationAccuracy:] Median location accuracy: 5.0 2024-12-21 16:37:30.960 ℹ️-[TSConfig persist] 2024-12-21 16:37:30.962 🔵-[TSConfig incrementOdometer:] 12001.1 2024-12-21 16:37:30.970 ℹ️+[LocationAuthorization run:onCancel:] status: 3 2024-12-21 16:37:30.971 ✅-[TSLocationManager persistLocation:]_block_invoke INSERT: 507EA2D9-A123-4D69-AA16-241230754ADC 2024-12-21 16:37:30.973 ✅-[BackgroundTaskManager createBackgroundTask] 105 2024-12-21 16:37:30.974 🔵-[LocationDAO allWithLocking:]_block_invoke LOCKED 1 RECORDS 2024-12-21 16:37:30.974 🔵-[TSHttpService postBatch:] 1 records 2024-12-21 16:37:31.809 🔵-[HttpResponse handleResponse] Response: 200 2024-12-21 16:37:31.809 ✅-[LocationDAO destroyAll:] DESTROY: 507EA2D9-A123-4D69-AA16-241230754ADC 2024-12-21 16:37:31.818 ✅-[LocationDAO destroyAll:]_block_invoke DESTROY SUCCESS (1) 2024-12-21 16:37:31.819 🔵-[LocationDAO allWithLocking:]_block_invoke LOCKED 0 RECORDS 2024-12-21 16:37:31.820 ✅-[BackgroundTaskManager stopBackgroundTask:]_block_invoke 105 OF ( 2024-12-21 16:37:36.613 🔵-[TSLocationManager calculateMedianLocationAccuracy:] Median location accuracy: 5.0 2024-12-21 16:37:36.613 ℹ️-[TSConfig persist] 2024-12-21 16:37:36.615 🔵-[TSConfig incrementOdometer:] 12087.7 2024-12-21 16:37:36.623 ✅-[TSLocationManager persistLocation:]_block_invoke INSERT: 7A1BD389-C9AE-4540-A8F3-1DF7978A0459 2024-12-21 16:37:40.924 🔵-[TSLocationManager onResume:] enabled? 1 |
Yes, because you don’t understand the nature of a terminated iOS app. When the iOS app is terminated, your app is completely wiped from memory. The only thing that will reawaken your app is to go move at least 200 meters. as explained in the api docs Config.stopOnTerminate. |
I have moved more than 200 meters, specifically 5 km. The application has recorded and synced the location to the server, but the business logic in JavaScript is not working. How can I check this? BackgroundGeolocation.onLocation( |
Search API docs "Logger" to learn how to insert your own custom logs into the plugin's log database (retrievable via method . |
Hi @christocracy ,
} 2024-12-29 19:13:13.324 ℹ️-[GeofenceDAO init] 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, 2024-12-29 19:13:13.324 ℹ️-[GeofenceDAO init] CREATE index IF NOT EXISTS identifier ON geofences (identifier);CREATE index IF NOT EXISTS latitude ON geofences (latitude);CREATE index IF NOT EXISTS longitude ON geofences (longitude);CREATE index IF NOT EXISTS sin_latitude ON geofences (sin_latitude);CREATE index IF NOT EXISTS cos_latitude ON geofences (cos_latitude);CREATE index IF NOT EXISTS sin_longitude ON geofences (sin_longitude);CREATE index IF NOT EXISTS cos_longitude ON geofences (cos_longitude); 2024-12-29 19:13:13.326 ℹ️-[TSLocationManager on:success:failure:] location 2024-12-29 19:13:13.326 ℹ️-[TSLocationManager on:success:failure:] motionchange 2024-12-29 19:13:13.326 ℹ️-[TSLocationManager on:success:failure:] activitychange 2024-12-29 19:13:13.326 ℹ️-[TSLocationManager on:success:failure:] heartbeat 2024-12-29 19:13:13.326 ℹ️-[TSGeofenceManager onGeofence:] 2024-12-29 19:13:13.326 ℹ️-[TSGeofenceManager onGeofencesChange:] 2024-12-29 19:13:13.326 ℹ️-[TSLocationManager on:success:failure:] http 2024-12-29 19:13:13.326 ℹ️-[TSLocationManager on:success:failure:] providerchange 2024-12-29 19:13:13.326 ℹ️-[TSLocationManager on:success:failure:] schedule 2024-12-29 19:13:13.326 ℹ️-[TSLocationManager on:success:failure:] powersavechange 2024-12-29 19:13:13.326 ℹ️-[TSHttpService onConnectivityChange:] 2024-12-29 19:13:13.326 ℹ️-[TSLocationManager on:success:failure:] enabledchange 2024-12-29 19:13:13.326 ℹ️-[TSHttpService onAuthorization:] 2024-12-29 19:13:13.368 🔵-[TSLocationManager locationManager:didChangeAuthorizationStatus:] status 3 2024-12-29 19:13:13.369 🔵-[LocationManager locationManager:didChangeAuthorizationStatus:] 3 2024-12-29 19:13:13.369 🔵-[PolygonGeofencingService locationManager:didChangeAuthorizationStatus:] 3 2024-12-29 19:13:13.369 🔵-[LocationManager locationManager:didChangeAuthorizationStatus:] 3 2024-12-29 19:13:13.369 🔵-[BackgroundTaskManager locationManager:didChangeAuthorizationStatus:] 3 2024-12-29 19:13:13.369 🔵-[LocationManager locationManager:didChangeAuthorizationStatus:] 3 2024-12-29 19:13:13.370 ℹ️+[LocationAuthorization run:onCancel:] status: 3 |
Those logs you posted are printed every time your app launches. They are completely normal. the plugin stores 3 days worth of logs in its database. See api docs .emailLog to learn how to fetch them. |
Hi Christocracy 2025-01-14 12:37:02.907
|
It seems your server doesn’t like the data provided to it.
|
Why can't I use BLE Central in the background on iOS?
Your Environment
npx cap doctor
): 6#ready
:Config
{
activityRecognitionInterval = 10000;
activityType = 1;
authorization = {
};
autoSync = 1;
autoSyncThreshold = 5;
batchSync = 1;
debug = 0;
desiredAccuracy = "-1";
desiredOdometerAccuracy = 10;
didDeviceReboot = 0;
didLaunchInBackground = 0;
didRequestUpgradeLocationAuthorization = 1;
disableAutoSyncOnCellular = 0;
disableElasticity = 0;
disableLocationAuthorizationAlert = 1;
disableMotionActivityUpdates = 0;
disableStopDetection = 0;
distanceFilter = 80;
elasticityMultiplier = 1;
enableTimestampMeta = 0;
enabled = 1;
extras = {
};
geofenceInitialTriggerEntry = 1;
geofenceProximityRadius = 2000;
geofenceTemplate = "";
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 = "{"latitude":<%= latitude %>, "longitude":<%= longitude %>, "speed":<%= speed %>, "is_moving":<%= is_moving %>, "timestamp":"<%= timestamp %>", "activityType":"<%= activity.type %>" }";
locationTimeout = 60;
locationsOrderDirection = ASC;
logLevel = 4;
logMaxDays = 3;
maxBatchSize = 5;
maxDaysToPersist = 3;
maxRecordsToPersist = "-1";
method = POST;
minimumActivityRecognitionConfidence = 70;
odometer = "9187.096271847497";
pausesLocationUpdatesAutomatically = 1;
persistMode = 2;
preventSuspend = 1;
schedule = (
);
schedulerEnabled = 0;
showsBackgroundLocationIndicator = 0;
startOnBoot = 1;
stationaryRadius = 80;
stopAfterElapsedMinutes = "-1";
stopDetectionDelay = 0;
stopOnStationary = 0;
stopOnTerminate = 0;
stopTimeout = 5;
trackingMode = 1;
triggerActivities = "";
useSignificantChangesOnly = 0;
}
I want to use BLE Central in the background on iOS. How can I achieve this?
The text was updated successfully, but these errors were encountered: