transistorsoft / capacitor-background-geolocation

The most sophisticated background location-tracking & geofencing module with battery-conscious motion-detection intelligence for iOS and Android.
MIT License
88 stars 14 forks source link

Location not updated when app terminated. #258

Closed iampapaisarkar closed 1 week ago

iampapaisarkar commented 1 week ago

Your Environment


## Expected Behavior
When app is foregrounded, it sends a notification to the device indicating whether the device is moving or stationary. However, when I terminate the app by swiping up from recent apps or backgrounded, the app should still send location update event notifications.

## Actual Behavior
Currently, when I open the app and it is running in the foreground, location tracking works. However, it does not work when the app is in the background or terminated.

## Steps to Reproduce
<!--- reproduce this issue; include code to reproduce, if relevant -->
1.
2.
3.
4.

## Context
<!--- What were you trying to do? -->

## Debug logs
<!-- include iOS / Android logs
- ios XCode logs,
- use #getLog / #emailLog methods (@see docs)
- Android: $ adb logcat
-->
<details>
    <summary>Logs</summary>

```<!-- Syntax highlighting:  DO NOT REMOVE -->
ℹ️-[TSDBLogger db_delete] maxAge: 259200
ℹ️-[TSLocationManager init] 
╔═════════════════════════════════════════════
║ TSLocationManager (build 388)
╠══════════════════════════════════════════════
{
    activityRecognitionInterval = 10000;
    activityType = 1;
    authorization =     {
    };
    autoSync = 1;
    autoSyncThreshold = 0;
    batchSync = 0;
    debug = 1;
    desiredAccuracy = "-1";
    desiredOdometerAccuracy = 100;
    didDeviceReboot = 0;
    didLaunchInBackground = 0;
    didRequestUpgradeLocationAuthorization = 1;
    disableAutoSyncOnCellular = 0;
    disableElasticity = 0;
    disableLocationAuthorizationAlert = 0;
    disableMotionActivityUpdates = 0;
    disableStopDetection = 0;
    distanceFilter = 5;
    elasticityMultiplier = 1;
    enableTimestampMeta = 0;
    enabled = 1;
    extras =     {
    };
    geofenceInitialTriggerEntry = 1;
    geofenceProximityRadius = 2000;
    geofenceTemplate = "";
    headers =     {
    };
    heartbeatInterval = 60;
    httpRootProperty = location;
    httpTimeout = 60000;
    iOSHasWarnedLocationServicesOff = 1;
    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 = "";
    locationTimeout = 60;
    locationsOrderDirection = ASC;
    logLevel = 5;
    logMaxDays = 3;
    maxBatchSize = "-1";
    maxDaysToPersist = 14;
    maxRecordsToPersist = "-1";
    method = POST;
    minimumActivityRecognitionConfidence = 70;
    odometer = "52743298.7784837";
    params =     {
    };
    pausesLocationUpdatesAutomatically = 1;
    persistMode = 2;
    preventSuspend = 0;
    schedule =     (
    );
    schedulerEnabled = 0;
    showsBackgroundLocationIndicator = 1;
    startOnBoot = 1;
    stationaryRadius = 25;
    stopAfterElapsedMinutes = "-1";
    stopDetectionDelay = 0;
    stopOnStationary = 0;
    stopOnTerminate = 0;
    stopTimeout = 1;
    trackingMode = 1;
    url = "";
    useSignificantChangesOnly = 0;
}
ℹ️-[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, loiteringDelay DOUBLE NOT NULL DEFAULT 0, extras TEXT, vertices TEXT)
ℹ️-[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);
ℹ️-[TSLocationManager on:success:failure:] location
ℹ️-[TSLocationManager on:success:failure:] motionchange
ℹ️-[TSLocationManager on:success:failure:] activitychange
ℹ️-[TSLocationManager on:success:failure:] heartbeat
ℹ️-[TSGeofenceManager onGeofence:]
ℹ️-[TSGeofenceManager onGeofencesChange:]
ℹ️-[TSLocationManager on:success:failure:] http
ℹ️-[TSLocationManager on:success:failure:] providerchange
ℹ️-[TSLocationManager on:success:failure:] schedule
ℹ️-[TSLocationManager on:success:failure:] powersavechange
ℹ️-[TSHttpService onConnectivityChange:]
ℹ️-[TSLocationManager on:success:failure:] enabledchange
ℹ️-[TSHttpService onAuthorization:]
10.28.1 - [FirebaseCore][I-COR000003] The default Firebase app has not yet been configured. Add `FirebaseApp.configure()` to your application initialization. This can be done in in the App Delegate's application(_:didFinishLaunchingWithOptions:)` (or the `@main` struct's initializer in SwiftUI). Read more: https://goo.gl/ctyzm8.
⚡️  Loading app at http://192.168.29.215:8081...
🔵-[TSLocationManager locationManager:didChangeAuthorizationStatus:] status 3
🔵-[LocationManager locationManager:didChangeAuthorizationStatus:] 3
🔵-[PolygonGeofencingService locationManager:didChangeAuthorizationStatus:] 3
🔵-[LocationManager locationManager:didChangeAuthorizationStatus:] 3
🔵-[BackgroundTaskManager locationManager:didChangeAuthorizationStatus:] 3
🔵-[LocationManager locationManager:didChangeAuthorizationStatus:] 3
ℹ️+[LocationAuthorization run:onCancel:] status: 3
SplashScreen.hideSplash: SplashScreen was automatically hidden after default timeout. You should call `SplashScreen.hide()` as soon as your web app is loaded (or increase the timeout). Read more at https://capacitorjs.com/docs/apis/splash-screen#hiding-the-splash-screen
⚡️  [info] - [Quasar] Running CAPACITOR.
⚡️  [warn] - Capacitor plugin "BackgroundGeolocation" already registered. Cannot register plugins twice.
⚡️  [log] - DEV:  App.vue -> beforeMount()
⚡️  To Native ->  CapacitorHttp request 130912442
⚡️  [log] - DEV:  Init Firebase
⚡️  To Native ->  CapacitorHttp request 130912443
⚡️  To Native ->  SplashScreen hide 130912444
⚡️  To Native ->  CapacitorHttp request 130912445
⚡️  [log] - DEV:  Init Native Firebase
⚡️  TO JS undefined
⚡️  [log] - DEV:  App.vue -> mounted()
⚡️  To Native ->  CapacitorHttp request 130912446
⚡️  [warn] - Google Maps JavaScript API has been loaded directly without loading=async. This can result in suboptimal performance. For best-practice loading patterns please see https://goo.gle/js-api-loading
⚡️  WebView loaded
⚡️  To Native ->  CapacitorHttp request 130912447
nw_connection_copy_connected_local_endpoint_block_invoke [C6] Client called nw_connection_copy_connected_local_endpoint on unconnected nw_connection
nw_connection_copy_connected_remote_endpoint_block_invoke [C6] Client called nw_connection_copy_connected_remote_endpoint on unconnected nw_connection
nw_connection_copy_protocol_metadata_internal_block_invoke [C6] Client called nw_connection_copy_protocol_metadata_internal on unconnected nw_connection
nw_connection_copy_connected_local_endpoint_block_invoke [C2] Connection has no local endpoint
nw_connection_copy_connected_local_endpoint_block_invoke [C2] Connection has no local endpoint
nw_connection_copy_connected_local_endpoint_block_invoke [C7] Client called nw_connection_copy_connected_local_endpoint on unconnected nw_connection
nw_connection_copy_connected_remote_endpoint_block_invoke [C7] Client called nw_connection_copy_connected_remote_endpoint on unconnected nw_connection
nw_connection_copy_protocol_metadata_internal_block_invoke [C7] Client called nw_connection_copy_protocol_metadata_internal on unconnected nw_connection
nw_connection_copy_connected_local_endpoint_block_invoke [C4] Connection has no local endpoint
nw_connection_copy_connected_local_endpoint_block_invoke [C4] Connection has no local endpoint
⚡️  TO JS {"data":"{\"info\":{\"status\":200,\"response\":\"success\",\"timestamp\":\"2024-06-26T06:47:44.807\",\"min_version\":\"3.5.0\",\"version\":\"3.5.0\",\"tech_info\":{\"SPID\":65,\"storedProcedure\":\"sp_dev_log\",\"apiCallLogId\":1014584}},\"data\":{\"dev\"
⚡️  TO JS {"status":200,"headers":{"Server":"Microsoft-IIS\/10.0","Content-Type":"application\/json; charset=utf-8","Date":"Wed, 26 Jun 2024 06:47:44 GMT"},"data":"{\"info\":{\"status\":200,\"response\":\"success\",\"timestamp\":\"2024-06-26T06:47:44.807\",\"min_ver
⚡️  TO JS {"url":"https:\/\/workerx.api.dev.logix26.com\/dev_log","data":"{\"info\":{\"status\":200,\"response\":\"success\",\"timestamp\":\"2024-06-26T06:47:44.810\",\"min_version\":\"3.5.0\",\"version\":\"3.5.0\",\"tech_info\":{\"SPID\":63,\"storedProcedure\":\"sp
⚡️  TO JS {"headers":{"Server":"Microsoft-IIS\/10.0","Content-Type":"application\/json; charset=utf-8","Date":"Wed, 26 Jun 2024 06:47:44 GMT"},"status":200,"url":"https:\/\/workerx.api.dev.logix26.com\/dev_log","data":"{\"info\":{\"status\":200,\"response\":\"succes
⚡️  TO JS {"data":{"kind":"identitytoolkit#GetAccountInfoResponse","users":[{"lastLoginAt":"1719384444162","displayName":"Papai Sarkar","providerUserInfo":[{"providerId":"password","email":"papai@logix26.com","displayName":"Papai Sarkar","federatedId":"papai@logix26
⚡️  [log] - DEV:  User is logged in with firebase {"uid":"MDA5SDk0fUPxz2xjyG5lDJqiF0i1","email":"papai@logix26.com","emailVerified":false,"displayName":"Papai Sarkar","isAnonymous":false,"providerData":[{"providerId":"password","uid":"papai@logix26.com","displayName":"Papai Sarkar","email":"papai@logix26.com","phoneNumber":null,"photoURL":null}],"stsTokenManager":{"refreshToken":"AMf-vBzztE0mO7v3l8mCRzwzJ2f8FFW7SeMZtjXKgDuVb_MYj2QP8z6kkPL11bZJS6ATZmRCetYBKLhJLGIdsDwPG75BEXexu26IfGwHROczra1QuvtOh_8JwjGANpUo5mjzrztunwYgA4eqrpjlAhx4s9AvyFF8iY8bsD-zvjdalrqeO8IhVR15w4BVB_jvpkIdIanMuQgRhBD4G9NdQVENzltHjEdHZr04q38_bZU-AjpEfsCNXA0","accessToken":"eyJhbGciOiJSUzI1NiIsImtpZCI6ImYwOGU2ZTNmNzg4ZDYwMTk0MDA1ZGJiYzE5NDc0YmY5Mjg5ZDM5ZWEiLCJ0eXAiOiJKV1QifQ.eyJuYW1lIjoiUGFwYWkgU2Fya2FyIiwiaXNzIjoiaHR0cHM6Ly9zZWN1cmV0b2tlbi5nb29nbGUuY29tL3dvcmtlcngtNDA3NTEwIiwiYXVkIjoid29ya2VyeC00MDc1MTAiLCJhdXRoX3RpbWUiOjE3MTkzODQ0NDQsInVzZXJfaWQiOiJNREE1U0RrMGZVUHh6MnhqeUc1bERKcWlGMGkxIiwic3ViIjoiTURBNVNEazBmVVB4ejJ4anlHNWxESnFpRjBpMSIsImlhdCI6MTcxOTM4NDQ0NCwiZXhwIjoxNzE5Mzg4MDQ0LCJlbWFpbCI6InBhcGFpQGxvZ2l4MjYuY29tIiwiZW1haWxfdmVyaWZpZWQiOmZhbHNlLCJmaXJlYmFzZSI6eyJpZGVudGl0aWVzIjp7ImVtYWlsIjpbInBhcGFpQGxvZ2l4MjYuY29tIl19LCJzaWduX2luX3Byb3ZpZGVyIjoicGFzc3dvcmQifX0.L7RaUqj6stu8PS_TWozaowd0tMf3upF2GwBD18Up3Eop22t5Lq3zxUhlj2y4C8RYalg-7NWhFAuuNZaye4SCgtA9imqmHyIX-feWqexovZeWKOwR0WvAV3TuZo6s1sMPw3GVmpzhsdqNi2VrIfBumqk47Vq9hoF7jDQ58XANsMd1PgCAaOea4ZzFJoc9A_RLbv09Ocz7GCB4_5cu9ktn271fzlP87i_-yrMtrEtmwjfMZkuDFHq9ONq0zEw2b5S_avtWTknp603rwExLDMDnwQ33eObvzbnWcLR9cfsUGWsS1SBPXjhbfAw8ZCB4iu96jjUWn8I0dkzfEvfxtYgeEQ","expirationTime":1719388044295},"createdAt":"1712563440898","lastLoginAt":"1719384444162","apiKey":"AIzaSyBhtajZTzT26SxgUgF90a_uN1vcR6b3qRs","appName":"[DEFAULT]"}
⚡️  To Native ->  FirebaseAuthentication getIdToken 130912449
[ FirebaseAuthentication ]  <CapacitorFirebaseAuthentication.RuntimeError: 0x6000006b4ba0>
ERROR MESSAGE:  {"message":"The operation couldn’t be completed. (CapacitorFirebaseAuthentication.RuntimeError error 1.)","errorMessage":"The operation couldn’t be completed. (CapacitorFirebaseAuthentication.RuntimeError error 1.)"}
⚡️  To Native ->  ⚡️  [error] - {"message":"The operation couldn’t be completed. (CapacitorFirebaseAuthentication.RuntimeError error 1.)","errorMessage":"The operation couldn’t be completed. (CapacitorFirebaseAuthentication.RuntimeError error 1.)"}
FirebaseAuthentication getIdToken 130912450
⚡️  [error] - {"errorMessage":"The operation couldn’t be completed. (CapacitorFirebaseAuthentication.RuntimeError error 1.)"}
[ FirebaseAuthentication ]  <CapacitorFirebaseAuthentication.RuntimeError: 0x6000006a9c60>
ERROR MESSAGE:  {"message":"The operation couldn’t be completed. (CapacitorFirebaseAuthentication.RuntimeError error 1.)","errorMessage":"The operation couldn’t be completed. (CapacitorFirebaseAuthentication.RuntimeError error 1.)"}
⚡️  [error] - {"message":"The operation couldn’t be completed. (CapacitorFirebaseAuthentication.RuntimeError error 1.)","errorMessage":"The operation couldn’t be completed. (CapacitorFirebaseAuthentication.RuntimeError error 1.)"}
⚡️  [error] - {"errorMessage":"The operation couldn’t be completed. (CapacitorFirebaseAuthentication.RuntimeError error 1.)"}
⚡️  To Native ->  CapacitorHttp request 130912451
Invalidating grant <invalid NS/CF object> failed
⚡️  TO JS {"status":200,"headers":{"Date":"Wed, 26 Jun 2024 06:47:44 GMT","Content-Length":"53878","Server":"Microsoft-IIS\/10.0","Content-Type":"application\/json; charset=utf-8"},"url":"https:\/\/workerx.api.dev.logix26.com\/route-list?__debug=1","data":"{\"info\"
⚡️  To Native ->  FirebaseAuthentication getIdToken 130912452
[ FirebaseAuthentication ]  <CapacitorFirebaseAuthentication.RuntimeError: 0x60000067e5c0>
ERROR MESSAGE:  {"errorMessage":"The operation couldn’t be completed. (CapacitorFirebaseAuthentication.RuntimeError error 1.)","message":"The operation couldn’t be completed. (CapacitorFirebaseAuthentication.RuntimeError error 1.)"}
⚡️  [error] - {"errorMessage":"The operation couldn’t be completed. (CapacitorFirebaseAuthentication.RuntimeError error 1.)","message":"The operation couldn’t be completed. (CapacitorFirebaseAuthentication.RuntimeError error 1.)"}
⚡️  [error] - {"errorMessage":"The operation couldn’t be completed. (CapacitorFirebaseAuthentication.RuntimeError error 1.)"}
⚡️  To Native ->  CapacitorHttp request 130912453
⚡️  TO JS {"data":"{\"info\":{\"status\":200,\"response\":\"success\",\"timestamp\":\"2024-06-26T06:47:46.283\",\"min_version\":\"3.5.0\",\"version\":\"3.5.0\",\"tech_info\":\"{\\\"SPID\\\":67,\\\"storedProcedure\\\":\\\"sp_time_log_fetch\\\",\\\"apiCallLogId\\\":10
⚡️  [log] - DEV:  Multi View URL: /multi-view-data?multi_view_id=6D1EA0E9-C111-4637-A3C0-30AC26451E88
⚡️  To Native ->  CapacitorHttp request 130912454
⚡️  To Native ->  FirebaseAuthentication getIdToken 130912455
⚡️  To Native ->  FirebaseAuthentication getIdToken 130912456
[ FirebaseAuthentication ]  <CapacitorFirebaseAuthentication.RuntimeError: 0x600000221f00>
[ FirebaseAuthentication ]  <CapacitorFirebaseAuthentication.RuntimeError: 0x600000223f60>
ERROR MESSAGE:  {"message":"The operation couldn’t be completed. (CapacitorFirebaseAuthentication.RuntimeError error 1.)","errorMessage":"The operation couldn’t be completed. (CapacitorFirebaseAuthentication.RuntimeError error 1.)"}
ERROR MESSAGE:  {"message":"The operation couldn’t be completed. (CapacitorFirebaseAuthentication.RuntimeError error 1.)","errorMessage":"The operation couldn’t be completed. (CapacitorFirebaseAuthentication.RuntimeError error 1.)"}
⚡️  [error] - {"message":"The operation couldn’t be completed. (CapacitorFirebaseAuthentication.RuntimeError error 1.)","errorMessage":"The operation couldn’t be completed. (CapacitorFirebaseAuthentication.RuntimeError error 1.)"}
⚡️  [error] - {"errorMessage":"The operation couldn’t be completed. (CapacitorFirebaseAuthentication.RuntimeError error 1.)"}
⚡️  To Native ->  CapacitorHttp request 130912457
⚡️  [error] - {"message":"The operation couldn’t be completed. (CapacitorFirebaseAuthentication.RuntimeError error 1.)","errorMessage":"The operation couldn’t be completed. (CapacitorFirebaseAuthentication.RuntimeError error 1.)"}
⚡️  [error] - {"errorMessage":"The operation couldn’t be completed. (CapacitorFirebaseAuthentication.RuntimeError error 1.)"}
⚡️  To Native ->  CapacitorHttp request 130912458
⚡️  TO JS {"data":"{\"info\":{\"status\":200,\"response\":\"success\",\"timestamp\":\"2024-06-26T06:47:48.073\",\"min_version\":\"3.5.0\",\"version\":\"3.5.0\",\"tech_info\":{\"SPID\":67,\"storedProcedure\":\"sp_dev_log\",\"apiCallLogId\":1014589}},\"data\":{\"dev\"
⚡️  TO JS {"headers":{"Server":"Microsoft-IIS\/10.0","Content-Type":"application\/json; charset=utf-8","Content-Length":"197","Date":"Wed, 26 Jun 2024 06:47:48 GMT"},"url":"https:\/\/workerx.api.dev.logix26.com\/page-info?__debug=1&route_id=196&main_id=","status":20
⚡️  TO JS {"status":200,"headers":{"Server":"Microsoft-IIS\/10.0","Date":"Wed, 26 Jun 2024 06:47:48 GMT","Content-Type":"application\/json; charset=utf-8","Content-Length":"1385"},"url":"https:\/\/workerx.api.dev.logix26.com\/multi-view-data?__debug=1&multi_view_id=
⚡️  [log] - DEV:  -- ListView.vue -> mounted()
⚡️  To Native ->  CapacitorHttp request 130912459
⚡️  To Native ->  BackgroundGeolocation addListener 130912460
⚡️  To Native ->  BackgroundGeolocation addListener 130912461
⚡️  To Native ->  BackgroundGeolocation addListener 130912462
⚡️  To Native ->  BackgroundGeolocation addListener 130912463
⚡️  To Native ->  BackgroundGeolocation ready 130912464
ℹ️-[TSConfig persist]
ℹ️-[TSConfig persist]
🔵-[TSLocationManager ready]
⚡️  TO JS {"status":3,"gps":true,"accuracyAuthorization":0,"enabled":true,"network":true}
ℹ️-[TSLocationManager doStart:] trackingMode: 1
ℹ️-[TSLocationManager loadLastOdometerLocation] <+51.50998000,-0.13370000> +/- -1.00m (speed -1.00 mps / course -1.00) @ 26/06/24, 12:17:48 PM India Standard Time
🎾-[TSGeofenceManager start]
🔵-[TSLocationManager setPace:] 0
⚡️  TO JS {"logLevel":5,"maxDaysToPersist":14,"httpRootProperty":"location","disableAutoSyncOnCellular":false,"method":"POST","pausesLocationUpdatesAutomatically":true,"stopTimeout":1,"stopAfterElapsedMinutes":-1,"disableElasticity":false,"desiredAccuracy":-1,"stopO
⚡️  To Native ->  CapacitorHttp request 130912465
⚡️  To Native ->  CapacitorHttp request 130912466
⚡️  To Native ->  CapacitorHttp request 130912467
⚡️  To Native ->  FirebaseAuthentication getIdToken 130912468
⚡️  [log] - DEV:  ListView.vue -> fetchListingIfVisible
⚡️  [log] - DEV:  Running 'fetchRecords' on ListView.vue
⚡️  [log] - DEV:  URL: /task-actions?search=&pagination_object={"page_number":1,"page_size":10,"total_records":10}
[ FirebaseAuthentication ]  <CapacitorFirebaseAuthentication.RuntimeError: 0x60000023ce60>
🎾-[TSLocationManager startUpdatingLocation] Location-services: ON

╔═══════════════════════════════════════════════════════════
║ -[TSHttpService flush:] 
╚═══════════════════════════════════════════════════════════

╔═══════════════════════════════════════════════════════════
║ -[TSHttpService finish:error:] Success: 0
╚═══════════════════════════════════════════════════════════
ℹ️+[LocationAuthorization run:onCancel:] status: 3
🎾-[TSLocationManager startMonitoringBackgroundFetch] BackgroundFetch: ON
⚡️  TO JS {"error":0}
ERROR MESSAGE:  {"errorMessage":"The operation couldn’t be completed. (CapacitorFirebaseAuthentication.RuntimeError error 1.)","message":"The operation couldn’t be completed. (CapacitorFirebaseAuthentication.RuntimeError error 1.)"}
⚡️  [error] - {"errorMessage":"The operation couldn’t be completed. (CapacitorFirebaseAuthentication.RuntimeError error 1.)","message":"The operation couldn’t be completed. (CapacitorFirebaseAuthentication.RuntimeError error 1.)"}
⚡️  [error] - {"errorMessage":"The operation couldn’t be completed. (CapacitorFirebaseAuthentication.RuntimeError error 1.)"}
⚡️  To Native ->  CapacitorHttp request 130912469
⚡️  TO JS {"status":200,"headers":{"Content-Length":"265","Content-Type":"application\/json; charset=utf-8","Server":"Microsoft-IIS\/10.0","Date":"Wed, 26 Jun 2024 06:47:48 GMT"},"data":"{\"info\":{\"status\":200,\"response\":\"success\",\"timestamp\":\"2024-06-26T0
⚠️-[TSLocationManager locationManager:didFailWithError:] Error Domain=kCLErrorDomain Code=0 "(null)"
🎾-[TSLocationManager startUpdatingLocation] Location-services: ON
[TSBackgroundFetch scheduleBGAppRefresh] com.transistorsoft.fetch
[TSBackgroundFetch] BGTaskScheduler failed to register fetch-task and will fall-back to old API.  This is likely due to running in the iOS Simulator (Error Domain=BGTaskSchedulerErrorDomain Code=1 "(null)")
ℹ️-[TSLocationManager startMonitoringBackgroundFetch]_block_invoke Configured BackgroundFetch
ℹ️+[LocationAuthorization run:onCancel:] status: 3
⚡️  TO JS {"data":"{\"info\":{\"status\":200,\"response\":\"success\",\"timestamp\":\"2024-06-26T06:47:48.577\",\"min_version\":\"3.5.0\",\"version\":\"3.5.0\",\"tech_info\":{\"SPID\":69,\"storedProcedure\":\"sp_dev_log\",\"apiCallLogId\":1014593}},\"data\":{\"dev\"
⚡️  TO JS {"data":"{\"info\":{\"status\":200,\"response\":\"success\",\"timestamp\":\"2024-06-26T06:47:48.583\",\"min_version\":\"3.5.0\",\"version\":\"3.5.0\",\"tech_info\":{\"SPID\":67,\"storedProcedure\":\"sp_dev_log\",\"apiCallLogId\":1014595}},\"data\":{\"dev\"
⚡️  TO JS {"status":200,"headers":{"Content-Type":"application\/json; charset=utf-8","Server":"Microsoft-IIS\/10.0","Date":"Wed, 26 Jun 2024 06:47:48 GMT","Content-Length":"265"},"data":"{\"info\":{\"status\":200,\"response\":\"success\",\"timestamp\":\"2024-06-26T0
⚡️  TO JS {"data":"{\"info\":{\"status\":200,\"response\":\"success\",\"pagination_object\":{\"total_records\":2,\"page_size\":10,\"page_number\":1,\"sort_by\":\"created_at\",\"sort_direction\":\"asc\"},\"timestamp\":\"2024-06-26T06:47:48.660\",\"min_version\":\"3.5
🔵-[TSLocationManager onSuspend:] enabled? 1)
🔵-[TSLocationManager setPace:] 0
🎾-[TSLocationManager startUpdatingLocation] Location-services: ON
ℹ️-[TSDBLogger db_save] Log committed
ℹ️+[LocationAuthorization run:onCancel:] status: 3
0x11301cd80 - ProcessThrottlerTimedActivity::activityTimedOut:
⚡️  To Native ->  FirebaseAuthentication getIdToken 130912470
[ FirebaseAuthentication ]  <CapacitorFirebaseAuthentication.RuntimeError: 0x60000024c660>
ERROR MESSAGE:  {"message":"The operation couldn’t be completed. (CapacitorFirebaseAuthentication.RuntimeError error 1.)","errorMessage":"The operation couldn’t be completed. (CapacitorFirebaseAuthentication.RuntimeError error 1.)"}
⚡️  [error] - {"message":"The operation couldn’t be completed. (CapacitorFirebaseAuthentication.RuntimeError error 1.)","errorMessage":"The operation couldn’t be completed. (CapacitorFirebaseAuthentication.RuntimeError error 1.)"}
⚡️  [error] - {"errorMessage":"The operation couldn’t be completed. (CapacitorFirebaseAuthentication.RuntimeError error 1.)"}
⚡️  To Native ->  CapacitorHttp request 130912471
⚡️  TO JS {"url":"https:\/\/workerx.api.dev.logix26.com\/notifications?popup_only=true&__debug=1","status":200,"data":"{\"info\":{\"status\":200,\"response\":\"success\",\"pagination_object\":{\"total_records\":0,\"page_size\":10,\"page_number\":1,\"sort_by\":\"sent
⚡️  TO JS {"location":{"mock":true,"activity":{"type":"unknown","confidence":100},"battery":{"is_charging":false,"level":-1},"coords":{"floor":null,"latitude":-22.903539299999998,"ellipsoidal_altitude":0,"accuracy":5,"speed":-1,"heading":-1,"altitude_accuracy":-1,"l
⚡️  TO JS {"age":47,"mock":true,"is_moving":false,"coords":{"heading_accuracy":-1,"speed":-1,"latitude":-22.903539299999998,"altitude_accuracy":-1,"accuracy":5,"ellipsoidal_altitude":0,"altitude":0,"floor":null,"speed_accuracy":-1,"heading":-1,"longitude":-43.209586

📍<-22.90353930,-43.20958690> +/- 5.00m (speed -1.00 mps / course -1.00) @ 26/06/24, 12:17:59 PM India Standard Time

╔═══════════════════════════════════════════════════════════
║ -[TSLocationManager locationManager:didUpdateLocations:] Enabled: 1 | isMoving: 0 | df: -1.0m | age: 34 ms
╚═══════════════════════════════════════════════════════════
✅-[TSLocationManager locationManager:didUpdateLocations:] Acquired motionchange position: <-22.90353930,-43.20958690> +/- 5.00m (speed -1.00 mps / course -1.00) @ 26/06/24, 12:17:59 PM India Standard Time
ℹ️-[TSConfig persist]
🔵-[TSConfig incrementOdometer:] 61996752.9
🔵-[TSLocationManager startMonitoringStationaryRegion:radius:] Radius: 200
🔴-[TSLocationManager stopUpdatingLocation]
🔵-[TSLocationManager calculateMedianLocationAccuracy:] Median location accuracy: 5.0
ℹ️-[PolygonGeofencingService setLocation:] Already updating location <IGNORED>
🎾-[TSLocationManager startMonitoringSignificantLocationChanges]
ℹ️-[PolygonGeofencingService setLocation:] Already updating location <IGNORED>
✅-[LocationDAO unlock]_block_invoke UNLOCKED ALL RECORDS
✅-[TSLocationManager persistLocation:]_block_invoke INSERT: 9057B121-7C1C-4A0A-897E-9BC849F5272C

╔═══════════════════════════════════════════════════════════
║ -[TSHttpService flush:] 
╚═══════════════════════════════════════════════════════════

╔═══════════════════════════════════════════════════════════
║ -[TSHttpService finish:error:] Success: 0
╚═══════════════════════════════════════════════════════════
Invalidating grant <invalid NS/CF object> failed
Invalidating grant <invalid NS/CF object> failed
Invalidating grant <invalid NS/CF object> failed
Invalidating grant <invalid NS/CF object> failed
Invalidating grant <invalid NS/CF object> failed
Invalidating grant <invalid NS/CF object> failed
⚡️  To Native ->  FirebaseAuthentication getIdToken 130912472
[ FirebaseAuthentication ]  <CapacitorFirebaseAuthentication.RuntimeError: 0x600000250360>
ERROR MESSAGE:  {"message":"The operation couldn’t be completed. (CapacitorFirebaseAuthentication.RuntimeError error 1.)","errorMessage":"The operation couldn’t be completed. (CapacitorFirebaseAuthentication.RuntimeError error 1.)"}
⚡️  [error] - {"message":"The operation couldn’t be completed. (CapacitorFirebaseAuthentication.RuntimeError error 1.)","errorMessage":"The operation couldn’t be completed. (CapacitorFirebaseAuthentication.RuntimeError error 1.)"}
⚡️  [error] - {"errorMessage":"The operation couldn’t be completed. (CapacitorFirebaseAuthentication.RuntimeError error 1.)"}
⚡️  To Native ->  CapacitorHttp request 130912473
⚡️  TO JS {"headers":{"Server":"Microsoft-IIS\/10.0","Content-Type":"application\/json; charset=utf-8","Date":"Wed, 26 Jun 2024 06:48:14 GMT","Content-Length":"391"},"data":"{\"info\":{\"status\":200,\"response\":\"success\",\"pagination_object\":{\"total_records\":
⚡️  To Native ->  FirebaseAuthentication getIdToken 130912474
[ FirebaseAuthentication ]  <CapacitorFirebaseAuthentication.RuntimeError: 0x600000228960>

christocracy commented 1 week ago

Launch your app in the iOS Simulator. Simulate location with Freeway Drive. Terminate app. Wait about 10s.

iampapaisarkar commented 1 week ago

I think it's working fine when the app is terminated only on simulator I just test it on my real device, it is not working on app terminate please see both video below.

Real Device Simulator

But I have other questions:

  1. If I set my server URL to get all current locations, will it always send?
  2. If I turn off mobile internet, what happens then?
  3. Is there a way to set up a region using a radius so that if a user enters or exits that area, the device will call the server in the background for a location update? Otherwise, it should not call the server API.
christocracy commented 1 week ago

If I set my server URL to get all current locations, will it always send?

Yes.

If I turn off mobile internet, what happens then?

The plugin was originally designed for offline operation, tracking emergency-workers in disaster zones where the cellular network is assumed to be destroyed. That's why the plugin first inserts each recorded location into its own SQLite database. When a network connection is restored, the plugin will automatically POST each record found in its database.

Is there a way to set up a region using a radius so that if a user enters or exits that area

This is called "Geofencing". Yes, the plugin implements the native Geofencing API for both iOS and Android. See API docs "Geofencing Guide"