Skip to content

[Help Wanted]: No location received when stopped #312

Open
@Swaghubinger

Description

@Swaghubinger

Required Reading

  • Confirmed

Plugin Version

6.1.0

Mobile operating-system(s)

  • iOS
  • Android

What do you require assistance about?

We have a problem where we only get the second to last location at the end of the route. So when the car is parked we don't get the location where the car is parked, instead the last location we get is when the car was still driving.
Usually this is a few hundred meters away and still at speed. We have some logic bound to when a car is stopped, and this never triggers now.

[Optional] Plugin Code and/or Config

Config comes from a config page in the App, and we tried a few different configurations. This is one of the configurations where we had this issue

const config = {
    distanceFilter: 10,
    elasticityMultiplier: 10,
    disableElasticity: false,
    locationUpdateInterval: 0,
    useSignificantChangesOnly: false,
    speedJumpFilter: 300,
    stopOnStationary: false,
    stopTimeout: 5,
    disableStopDetection: true,
    allowIdenticalLocations: false,
    deferTime: 1000 * 60,
    triggerOnActivity: true,
    motionTriggerDelay: 0,
    autoSyncThreshold: 0,
    batchSync: false,
    logMaxDays: 3,
    maxDaysToPersist: 3,
    maxRecordsToPersist: -1,
    heartbeatInterval: 60,
    sendOnHeartbeat: true,
    sendOnActivityChange: true,
    sendOnMotionChange: true,
    debug: false,
    apiEndpointBase: environment.production ? 'prod' : 'qa',
  }

await BackgroundGeolocation.ready({
      backgroundPermissionRationale: {
        message: ""
      },

      // Customized Config
      distanceFilter: config.distanceFilter,
      elasticityMultiplier: config.elasticityMultiplier,
      disableElasticity: config.disableElasticity,
      locationUpdateInterval: config.locationUpdateInterval,
      useSignificantChangesOnly: config.useSignificantChangesOnly,
      speedJumpFilter: config.speedJumpFilter,
      allowIdenticalLocations: config.allowIdenticalLocations,
      triggerActivities: config.triggerOnActivity ? 'in_vehicle' : undefined,
      motionTriggerDelay: config.motionTriggerDelay,
      stopOnStationary: config.stopOnStationary,
      stopTimeout: config.stopTimeout,
      disableStopDetection: config.disableStopDetection,
      deferTime: config.deferTime,
      autoSyncThreshold: config.autoSyncThreshold,
      batchSync: config.batchSync,
      logMaxDays: config.maxDaysToPersist,
      maxDaysToPersist: config.maxDaysToPersist,
      maxRecordsToPersist: config.maxRecordsToPersist,
      heartbeatInterval: config.heartbeatInterval,

      // Fixed Config
      desiredAccuracy: BackgroundGeolocation.DESIRED_ACCURACY_HIGH,
      geofenceModeHighAccuracy: true,
      autoSync: true,
      enableTimestampMeta: true,
      foregroundService: true,
      notification: {
        title: 'Title',
        text: 'Text',
        sticky: true,
        color: '#E61B5B',
        channelName: 'Channel',
        channelId: 'pos-tracking',
        priority: BackgroundGeolocation.NOTIFICATION_PRIORITY_MAX,
      },
      debug: config.debug,
      logLevel: BackgroundGeolocation.LOG_LEVEL_VERBOSE,
      stopOnTerminate: false,
      startOnBoot: true,
      url: this.envService.getApiEndpoint(config.apiEndpointBase),
      headers: {
        Authorization: 'Bearer ' + this.locationDataService.apiKey
      },
      params: {
        licensePlate: this.locationDataService.licensePlate,
        deviceId: this.locationDataService.deviceId,
        version: this.versionService.appVersion$.value,
        moving: this.moveState
      }
    });
    await BackgroundGeolocation.start();

    BackgroundGeolocation.onHttp(response => {
      if (response.success) {
        this.locationDataService.setConnectionSuccess();
      } else {
        this.locationDataService.setConnectionError(response.status, response.responseText);
      }
    });

    if(config.sendOnHeartbeat) {
      BackgroundGeolocation.onHeartbeat(async () => {
        await BackgroundGeolocation.getCurrentPosition({
          persist: true,
        });
        await BackgroundGeolocation.sync();
      })
    }
    if(config.sendOnMotionChange) {
      BackgroundGeolocation.onMotionChange(async (ev) => {
        await BackgroundGeolocation.getCurrentPosition({
          persist: true,
        });
        await BackgroundGeolocation.sync();
      })
    }
    if(config.sendOnActivityChange) {
      BackgroundGeolocation.onActivityChange(async (ev) => {
        await BackgroundGeolocation.getCurrentPosition({
          persist: true,
        });
        await BackgroundGeolocation.sync();
      })
    }

[Optional] Relevant log output

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions