flutter_background_geolocation icon indicating copy to clipboard operation
flutter_background_geolocation copied to clipboard

Heartbeat/Http Event does not include extras parameter

Open yashhema opened this issue 3 years ago • 4 comments

Your Environment

  • Plugin version: 4.3
  • Platform: Android
  • OS version: 11
  • Device manufacturer / model: Emulator
  • Flutter info (flutter doctor):
  • Plugin config:
PASTE_YOUR_CODE_HERE
```var conf = bg.Config(
        desiredAccuracy: bg.Config.DESIRED_ACCURACY_HIGH,

        backgroundPermissionRationale: bg.PermissionRationale(
            title:
            "Allow {applicationName} to access this device's location even when the app is closed or not in use.",
            message:
            "This app collects location data to enable recording your trips to work and calculate distance-travelled.",
            positiveAction: 'Change to "{backgroundPermissionOptionLabel}"',
            negativeAction: 'Cancel'),
        //locationUpdateInterval: 5000,
        activityType: Config.ACTIVITY_TYPE_OTHER_NAVIGATION,
        distanceFilter: 20,
        stopOnTerminate: true,
        startOnBoot: true,
        heartbeatInterval: 60,
        debug: true,
        autoSync: true,
        autoSyncThreshold: 1,
        locationsOrderDirection: "DESC",
        maxDaysToPersist: 1,
        url: serverurl,
        httpTimeout: 160000,
        extras: httpcallableformat,
        headers: {
          "Authorization": "Bearer ${authtoken}"
        },

        logLevel: bg.Config.LOG_LEVEL_VERBOSE);

## Expected Behavior
<!--- Tell us what should happen -->
Heartbeat/http event does not carry parameter provided in he httpcallableformat
## Actual Behavior
<!--- Tell us what happens instead -->
Extraparameters are not taken as part of http payload
## 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 -s TSLocationManager
-->
<details>
	<summary>Logs</summary>

``` <!-- syntax-highligting:  DO NOT REMOVE -->
PASTE_YOUR_LOGS_HERE

I/TSLocationManager(13763): 🔵 HTTP POST: 4728c9bf-9f51-45f9-8580-1594e92f426c I/flutter (13763): {"data":{"adhocactionmodel":{"staffid":"qjFne92NcLb7rNB5XRSQlAMoTE72"},"qrytype":"GETINITIALDATAFORSTAFFADHOCTRIP"}} W/TSLocationManager(13763): [c.t.l.http.HttpService$h onFailure] W/TSLocationManager(13763): ⚠️ Response: 0, timeout I/flutter (13763): [onHttp] status: 0, success? false, responseText: timeout D/TSLocationManager(13763): [c.t.l.data.sqlite.b unlock] D/TSLocationManager(13763): ✅ UNLOCKED: 4728c9bf-9f51-45f9-8580-1594e92f426c I/TSLocationManager(13763): [c.t.l.u.BackgroundTaskManager$Task stop] ⏳ stopBackgroundTask: 1 D/TSLocationManager(13763): [c.t.l.service.AbstractService finish] ⚙️︎ finish BackgroundTaskService [eventCount: 0, sticky: false] D/TSLocationManager(13763): [c.t.l.service.AbstractService onDestroy] D/TSLocationManager(13763): 🔴 BackgroundTaskService stopped I/TSLocationManager(13763): [c.t.l.s.TSScheduleManager oneShot] I/TSLocationManager(13763): ⏰ Scheduled OneShot: http_flush in 900000ms (jobID: 1267146893) D/TSLocationManager(13763): [c.t.l.service.AbstractService start] D/TSLocationManager(13763): 🎾 HeartbeatService [eventCount: 1] D/TSLocationManager(13763): [c.t.l.s.HeartbeatService$a run] ❤️ I/TSLocationManager(13763): [c.t.l.http.HttpService flush] I/TSLocationManager(13763): ╔═════════════════════════════════════════════ I/TSLocationManager(13763): ║ HTTP Service (count: 2) I/TSLocationManager(13763): ╠═════════════════════════════════════════════ D/TSLocationManager(13763): [c.t.l.service.AbstractService finish] ⚙️︎ finish HeartbeatService [eventCount: 0, sticky: false] D/TSLocationManager(13763): [c.t.l.service.AbstractService start] D/TSLocationManager(13763): 🎾 BackgroundTaskService [eventCount: 1] I/TSLocationManager(13763): [c.t.l.u.BackgroundTaskManager$Task start] ⏳ startBackgroundTask: 2 I/flutter (13763): [motionchange] - [HeartbeatEvent location:[Location {odometer: 8395152.0, activity: {confidence: 100, type: still}, extras: {ttyp: PEOPLE, vtyp: BUS, rname: MO1pPCcSeGhtC8PaE1Y3, allowedspid: [], spid: 5710369616035840, userid: qjFne92NcLb7rNB5XRSQlAMoTE72}, event: heartbeat, battery: {level: 1.0, is_charging: false}, uuid: ab484f3e-d193-4730-8683-55f4806ed7cb, coords: {altitude: 0.0, heading: 0.0, latitude: 53.475561666666664, accuracy: 5.0, heading_accuracy: 30.0, altitude_accuracy: 0.5, speed_accuracy: 0.5, speed: 0.0, longitude: -2.3200616666666667, ellipsoidal_altitude: 0.0}, is_moving: false, timestamp: 2022-10-24T18:47:26.386Z}]].location!.toString() D/TSLocationManager(13763): [c.t.l.data.sqlite.b first] D/TSLocationManager(13763): ✅ Locked 1 records I/TSLocationManager(13763): [c.t.l.http.HttpService a] I/TSLocationManager(13763): 🔵 HTTP POST: 4728c9bf-9f51-45f9-8580-1594e92f426c D/TSLocationManager(13763): [c.t.l.service.AbstractService onDestroy] D/TSLocationManager(13763): 🔴 HeartbeatService stopped V/MediaPlayer(13763): resetDrmState: mDrmInfo=null mDrmProvisioningThread=null mPrepareDrmInProgress=false mActiveDrmScheme=false V/MediaPlayer(13763): cleanDrmObj: mDrmObj=null mDrmSessionId=null W/TSLocationManager(13763): [c.t.l.http.HttpService$h onFailure] W/TSLocationManager(13763): ⚠️ Response: 0, timeout I/flutter (13763): [onHttp] status: 0, success? false, responseText: timeout D/TSLocationManager(13763): [c.t.l.data.sqlite.b unlock] D/TSLocationManager(13763): ✅ UNLOCKED: 4728c9bf-9f51-45f9-8580-1594e92f426c I/TSLocationManager(13763): [c.t.l.u.BackgroundTaskManager$Task stop] ⏳ stopBackgroundTask: 2 D/TSLocationManager(13763): [c.t.l.service.AbstractService finish] ⚙️︎ finish BackgroundTaskService [eventCount: 0, sticky: false] D/TSLocationManager(13763): [c.t.l.service.AbstractService onDestroy] D/TSLocationManager(13763): 🔴 BackgroundTaskService stopped I/TSLocationManager(13763): [c.t.l.s.TSScheduleManager oneShot] I/TSLocationManager(13763): ⏰ Oneshot http_flush is already pending W/System (13763): Ignoring header X-Firebase-Locale because its value was null. D/FirebaseAuth(13763): Notifying id token listeners about user ( qjFne92NcLb7rNB5XRSQlAMoTE72 ). I/flutter (13763): {"data":{"dto":null,"driverlist":null,"drivercardlist":null,"id":null,"actionrecordlist":null,"qrycode":null,"errorid":0,"errormsg":null,"peopleinfo":null}} D/TSLocationManager(13763): [c.t.l.service.AbstractService start] D/TSLocationManager(13763): 🎾 HeartbeatService [eventCount: 1] D/TSLocationManager(13763): [c.t.l.s.HeartbeatService$a run] ❤️ I/TSLocationManager(13763): [c.t.l.http.HttpService flush] I/TSLocationManager(13763): ╔═════════════════════════════════════════════ I/TSLocationManager(13763): ║ HTTP Service (count: 2) I/TSLocationManager(13763): ╠═════════════════════════════════════════════ D/TSLocationManager(13763): [c.t.l.service.AbstractService finish] ⚙️︎ finish HeartbeatService [eventCount: 0, sticky: false] D/TSLocationManager(13763): [c.t.l.service.AbstractService start] D/TSLocationManager(13763): 🎾 BackgroundTaskService [eventCount: 1] I/TSLocationManager(13763): [c.t.l.u.BackgroundTaskManager$Task start] ⏳ startBackgroundTask: 3 I/flutter (13763): [motionchange] - [HeartbeatEvent location:[Location {odometer: 8395152.0, activity: {confidence: 100, type: still}, extras: {ttyp: PEOPLE, vtyp: BUS, rname: MO1pPCcSeGhtC8PaE1Y3, allowedspid: [], spid: 5710369616035840, userid: qjFne92NcLb7rNB5XRSQlAMoTE72}, event: heartbeat, battery: {level: 1.0, is_charging: false}, uuid: 6953a3f4-cb78-47fa-a8bf-33b0d93a58d2, coords: {altitude: 0.0, heading: 0.0, latitude: 53.475561666666664, accuracy: 5.0, heading_accuracy: 30.0, altitude_accuracy: 0.5, speed_accuracy: 0.5, speed: 0.0, longitude: -2.3200616666666667, ellipsoidal_altitude: 0.0}, is_moving: false, timestamp: 2022-10-24T18:47:26.386Z}]].location!.toString() D/TSLocationManager(13763): [c.t.l.data.sqlite.b first] D/TSLocationManager(13763): ✅ Locked 1 records I/TSLocationManager(13763): [c.t.l.http.HttpService a] I/TSLocationManager(13763): 🔵 HTTP POST: 4728c9bf-9f51-45f9-8580-1594e92f426c I/TSLocationManager(13763): [c.t.l.http.HttpService$h onResponse] I/TSLocationManager(13763): 🔵 Response: 200 I/flutter (13763): [onHttp] status: 200, success? true, responseText: {"data":"Undefined rname"} D/TSLocationManager(13763): [c.t.l.data.sqlite.b destroy] D/TSLocationManager(13763): ✅ DESTROY: 4728c9bf-9f51-45f9-8580-1594e92f426c D/TSLocationManager(13763): [c.t.l.data.sqlite.b first] D/TSLocationManager(13763): ✅ Locked 1 records I/TSLocationManager(13763): [c.t.l.http.HttpService a] I/TSLocationManager(13763): 🔵 HTTP POST: 69f933ab-cda4-4c14-87d9-57c5001b9ea3 I/TSLocationManager(13763): [c.t.l.http.HttpService$h onResponse] I/TSLocationManager(13763): 🔵 Response: 200 I/flutter (13763): [onHttp] status: 200, success? true, responseText: {"data":"Undefined rname"} D/TSLocationManager(13763): [c.t.l.data.sqlite.b destroy] D/TSLocationManager(13763): ✅ DESTROY: 69f933ab-cda4-4c14-87d9-57c5001b9ea3 I/TSLocationManager(13763): [c.t.l.u.BackgroundTaskManager$Task stop] ⏳ stopBackgroundTask: 3 D/TSLocationManager(13763): [c.t.l.service.AbstractService finish] ⚙️︎ finish BackgroundTaskService [eventCount: 0, sticky: false] D/TSLocationManager(13763): [c.t.l.service.AbstractService onDestroy] D/TSLocationManager(13763): 🔴 BackgroundTaskService stopped D/TSLocationManager(13763): [c.t.l.service.AbstractService onDestroy] D/TSLocationManager(13763): 🔴 HeartbeatService stopped V/MediaPlayer(13763): resetDrmState: mDrmInfo=null mDrmProvisioningThread=null mPrepareDrmInProgress=false mActiveDrmScheme=false V/MediaPlayer(13763): cleanDrmObj: mDrmObj=null mDrmSessionId=null D/TSLocationManager(13763): [c.t.l.service.AbstractService start] D/TSLocationManager(13763): 🎾 HeartbeatService [eventCount: 1] D/TSLocationManager(13763): [c.t.l.s.HeartbeatService$a run] ❤️ D/TSLocationManager(13763): [c.t.l.service.AbstractService finish] ⚙️︎ finish HeartbeatService [eventCount: 0, sticky: false]

yashhema avatar Oct 30 '22 09:10 yashhema

Heartbeat/Http Event does not include extras parameter

What makes you think that?

christocracy avatar Oct 30 '22 14:10 christocracy

This is the message which we recv on server {"location":{"is_moving":false,"uuid":"d90edd55-5434-4679-963c-171ccc164207","timestamp":"2022-10-30T18:02:42.006Z","odometer":8395152,"coords":{"latitude":53.475561666666664,"longitude":-2.3200616666666667,"accuracy":5,"speed":0,"speed_accuracy":0.5,"heading":0,"heading_accuracy":30,"altitude":0,"ellipsoidal_altitude":0,"altitude_accuracy":0.5},"activity":{"type":"still","confidence":100},"battery":{"is_charging":false,"level":1},"extras":{}}}

And sometimes we also recv message with extras values filled. For us , we need the extras other wise we are unable to determine user

Also one of the things we have observed , we see lots of time out , If u see the configuration I posed , we increased the time out value to a big number , still time out is coming

We are right now forcing the server to send 200 anytime it recvs any message

W/TSLocationManager(17659): [c.t.l.http.HttpService$h onFailure] W/TSLocationManager(17659): ⚠️ Response: 0, timeout D/TSLocationManager(17659): [c.t.l.data.sqlite.b unlock] D/TSLocationManager(17659): ✅ UNLOCKED: 85ce1685-ce45-4014-85d5-8a85a4a28bb4 I/TSLocationManager(17659): [c.t.l.u.BackgroundTaskManager$Task stop] ⏳ stopBackgroundTask: 6 D/TSLocationManager(17659): [c.t.l.service.AbstractService finish] ⚙️︎ finish BackgroundTaskService [eventCount: 0, sticky: false] D/TSLocationManager(17659): [c.t.l.service.AbstractService onDestroy] D/TSLocationManager(17659): 🔴 BackgroundTaskService stopped I/TSLocationManager(17659): [c.t.l.s.TSScheduleManager oneShot] I/TSLocationManager(17659): ⏰ Oneshot http_flush is already pending D/TSLocationManager(17659): [c.t.l.service.AbstractService start] D/TSLocationManager(17659): 🎾 HeartbeatService [eventCount: 1] D/TSLocationManager(17659): [c.t.l.s.HeartbeatService$a run] ❤️ I/flutter (17659): {"data":{"dsrequest":{"plocinfo":{"lati":53.475561666666664,"longi":-2.3200616666666667,"reptime":1667549159,"spid":"5710369616035840","userid":"qjFne92NcLb7rNB5XRSQlAMoTE72","ttyp":"VEHICLE","vtyp":"BUS"},"rname":"MO1pPCcSeGhtC8PaE1Y3","id":"qjFne92NcLb7rNB5XRSQlAMoTE72"},"qrytype":"TPEOPLELOC"}} I/TSLocationManager(17659): [c.t.l.http.HttpService flush] I/TSLocationManager(17659): ╔═════════════════════════════════════════════ I/TSLocationManager(17659): ║ HTTP Service (count: 4) I/TSLocationManager(17659): ╠═════════════════════════════════════════════ D/TSLocationManager(17659): [c.t.l.service.AbstractService finish] ⚙️︎ finish HeartbeatService [eventCount: 0, sticky: false] D/TSLocationManager(17659): [c.t.l.service.AbstractService start] D/TSLocationManager(17659): 🎾 BackgroundTaskService [eventCount: 1] I/TSLocationManager(17659): [c.t.l.u.BackgroundTaskManager$Task start] ⏳ startBackgroundTask: 7 D/TSLocationManager(17659): [c.t.l.data.sqlite.b first] D/TSLocationManager(17659): ✅ Locked 1 records I/TSLocationManager(17659): [c.t.l.http.HttpService a] I/TSLocationManager(17659): 🔵 HTTP POST: 85ce1685-ce45-4014-85d5-8a85a4a28bb4 I/TSLocationManager(17659): [c.t.l.http.HttpService$h onResponse] I/TSLocationManager(17659): 🔵 Response: 200 D/TSLocationManager(17659): [c.t.l.data.sqlite.b destroy] D/TSLocationManager(17659): ✅ DESTROY: 85ce1685-ce45-4014-85d5-8a85a4a28bb4 D/TSLocationManager(17659): [c.t.l.data.sqlite.b first]

yashhema avatar Nov 04 '22 08:11 yashhema

The plugin does not POST a location in the onHeartbeat event. How are you posting a location in the onHeartbeat event?

christocracy avatar Nov 04 '22 14:11 christocracy

we need the extras other wise we are unable to determine user

You need to do that with Config.extras. It would make more sense to use Config.params for that sort of thing.

  • Config.extras are appended to each location
  • Config.params are appended to each HTTP request.

I suspect you are manually posting the event.location provided to the onHeartbeat event. That location is stale (the last known location). It is not a freshly recorded location. onHeartbeat does not turn on location-services.

If you want a fresh location in your onHeartbeat event, call upon .getCurrentPosition(options).

christocracy avatar Nov 04 '22 14:11 christocracy

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] avatar May 23 '24 01:05 github-actions[bot]

This issue was closed because it has been inactive for 14 days since being marked as stale.

github-actions[bot] avatar Jun 06 '24 01:06 github-actions[bot]