transistorsoft / cordova-background-geolocation-lt

The most sophisticated background location-tracking & geofencing module with battery-conscious motion-detection intelligence for iOS and Android.
http://www.transistorsoft.com/shop/products/cordova-background-geolocation
Other
655 stars 277 forks source link

Delay in getting location #487

Closed ReemaBegum closed 6 years ago

ReemaBegum commented 6 years ago

When background geolocation is called taking more time to fetch location service . Any suggesstion on this will help me lot ?

Your Environment

christocracy commented 6 years ago

I have no idea what this means. Show me what you mean with logs.

ReemaBegum commented 6 years ago

When I hit background geolocation plugin not getting response soon taking long time Here is my code var bgGeo = window.BackgroundGeolocation; // BackgroundGeolocation is highly configurable. See platform specific configuration options bgGeo.configure(callbackFn, failureFn, { desiredAccuracy: 0, stationaryRadius: 0, distanceFilter: 0, useSignificantChangesOnly: false, debug: false, stopOnTerminate: true, startOnBoot: false, stopTimeout: 1, stopDetectionDelay:0 }); // Turn ON the background-geolocation system. The user will be tracked whenever they suspend the app. bgGeo.start(); function callbackFn(location) { var coords = location.coords; var lat = coords.latitude; var lng = coords.longitude; } CallbackFn is not executing

christocracy commented 6 years ago

Please use 3-backticks to format code.

christocracy commented 6 years ago

And show me logs

ReemaBegum commented 6 years ago

Can you suggest me how to get log ?

christocracy commented 6 years ago

See Wiki Debugging

ReemaBegum commented 6 years ago

This is my log 09-26 18:29:54.930 5293 5293 I TSLocationManager: [c.t.l.a.BackgroundGeolocation removeActivityUpdates] 09-26 18:29:54.930 5293 5293 I TSLocationManager: 🔴 Stop activity updates 09-26 18:29:54.931 5293 5853 I TSLocationManager: [c.t.l.l.TSLocationManager onSingleLocationResult] 09-26 18:29:54.931 5293 5853 I TSLocationManager: 🔵 Acquired motionchange position, isMoving: false 09-26 18:29:54.989 5293 5293 D TSLocationManager: [c.t.l.l.TSLocationManager stopSingleLocationRequests] 09-26 18:29:54.989 5293 5293 D TSLocationManager: 🔴 Stop LocationRequest: 1009 09-26 18:29:55.017 5293 5853 D TSLocationManager: [c.t.l.l.TSLocationManager calculateMedianAccuracy] 24.18 09-26 18:29:55.039 5293 5293 D TSLocationManager: [c.t.l.a.BackgroundGeolocation isMainActivityActive] YES 09-26 18:29:55.052 5293 5293 I TSLocationManager: [c.t.l.BackgroundGeolocationService j] 09-26 18:29:55.052 5293 5293 I TSLocationManager: 🔴 Stop heartbeat

ReemaBegum commented 6 years ago

Actual behavior

  1. When I click on button to get location some times taking time to load success call back ?

Expected behavior

  1. Need to get location if device is in both stationary and moving state

    Steps to Reproduce

    Below is my code bgGeo.configure(callbackFn, failureFn, { desiredAccuracy: 0, stationaryRadius: 0, distanceFilter: 0, useSignificantChangesOnly: false, debug: false, stopOnTerminate: true, startOnBoot: false, stopTimeout: 1, stopDetectionDelay:0 });

christocracy commented 6 years ago

And what is your code doing when you "click on this button"?

christocracy commented 6 years ago
ReemaBegum commented 6 years ago

I don't need to display any notification and sounds so set debug :false . Suggest me why it is taking time to get location when device is stationary state

ReemaBegum commented 6 years ago

On click of a button I need to get address by using latitude and longitude by making use of background geolocation am getting lat and long

christocracy commented 6 years ago

Because the plugin samples multiple locations to find the most accurate possible. This can take some seconds. With debug: true, you will hear these samples as the dial-tone sound.

Assuming you're using #getCurrentPosition (I don't know, since you didn't show me your code), you might be interested in the samples config option.

christocracy commented 6 years ago

Here's the logs from executing #getCurrentPosition: Multiple locations are fetched.

09-26 09:18:01.074 30141 30368 D TSLocationManager: $ getCurrentPosition()
09-26 09:18:01.172 30141 31578 I TSLocationManager: [c.t.l.LocationService onLocation]
09-26 09:18:01.172 30141 31578 I TSLocationManager:   ℹ️  Location availability: true

09-26 09:18:03.513 30141 31579 D TSLocationManager: [c.t.l.LocationService onLocation]
09-26 09:18:03.513 30141 31579 D TSLocationManager: ╔═════════════════════════════════════════════
09-26 09:18:03.513 30141 31579 D TSLocationManager: ║ LocationService: location:1005
09-26 09:18:03.513 30141 31579 D TSLocationManager: ╠═════════════════════════════════════════════
09-26 09:18:03.513 30141 31579 D TSLocationManager: ╟─ 📍  Location[fused 45.519294,-73.616974 hAcc=19 et=+13d3h27m40s456ms vAcc=??? sAcc=??? bAcc=???], age: 257ms
09-26 09:18:03.538 30141 31579 D TSLocationManager: [c.t.l.l.TSLocationManager calculateMedianAccuracy] 19.4305
09-26 09:18:03.569 14208 14208 D TSLocationManager: [c.t.l.a.BackgroundGeolocation isMainActivityActive] YES
09-26 09:18:05.335 14208 31581 D TSLocationManager: [c.t.l.LocationService onHeartbeat] ❤️
09-26 09:18:05.385 14208 14208 D TSLocationManager: [c.t.l.a.BackgroundGeolocation isMainActivityActive] YES
09-26 09:18:08.440 30141 31584 D TSLocationManager: [c.t.l.LocationService onLocation]
09-26 09:18:08.440 30141 31584 D TSLocationManager: ╔═════════════════════════════════════════════
09-26 09:18:08.440 30141 31584 D TSLocationManager: ║ LocationService: location:1005
09-26 09:18:08.440 30141 31584 D TSLocationManager: ╠═════════════════════════════════════════════
09-26 09:18:08.440 30141 31584 D TSLocationManager: ╟─ 📍  Location[fused 45.519304,-73.616981 hAcc=19 et=+13d3h27m45s469ms vAcc=??? sAcc=??? bAcc=???], age: 169ms
09-26 09:18:08.462 30141 31584 D TSLocationManager: [c.t.l.l.TSLocationManager calculateMedianAccuracy] 19.429
09-26 09:18:08.504 14208 14208 D TSLocationManager: [c.t.l.a.BackgroundGeolocation isMainActivityActive] YES
09-26 09:18:13.451 30141 31587 D TSLocationManager: [c.t.l.LocationService onLocation]
09-26 09:18:13.451 30141 31587 D TSLocationManager: ╔═════════════════════════════════════════════
09-26 09:18:13.451 30141 31587 D TSLocationManager: ║ LocationService: location:1005
09-26 09:18:13.451 30141 31587 D TSLocationManager: ╠═════════════════════════════════════════════
09-26 09:18:13.451 30141 31587 D TSLocationManager: ╟─ 📍  Location[fused 45.519304,-73.616981 hAcc=19 et=+13d3h27m50s488ms vAcc=??? sAcc=??? bAcc=???], age: 158ms
09-26 09:18:13.476 30141 31587 D TSLocationManager: [c.t.l.l.TSLocationManager calculateMedianAccuracy] 19.41
09-26 09:18:13.519 14208 14208 D TSLocationManager: [c.t.l.a.BackgroundGeolocation isMainActivityActive] YES
09-26 09:18:18.487 30141 31593 D TSLocationManager: [c.t.l.LocationService onLocation]
09-26 09:18:18.487 30141 31593 D TSLocationManager: ╔═════════════════════════════════════════════
09-26 09:18:18.487 30141 31593 D TSLocationManager: ║ LocationService: location:1005
09-26 09:18:18.487 30141 31593 D TSLocationManager: ╠═════════════════════════════════════════════
09-26 09:18:18.487 30141 31593 D TSLocationManager: ╟─ 📍  Location[fused 45.519294,-73.616974 hAcc=19 et=+13d3h27m55s508ms vAcc=??? sAcc=??? bAcc=???], age: 177ms
09-26 09:18:18.531 30141 31593 D TSLocationManager: [c.t.l.l.TSLocationManager calculateMedianAccuracy] 19.391
09-26 09:18:18.586 14208 14208 D TSLocationManager: [c.t.l.a.BackgroundGeolocation isMainActivityActive] YES
09-26 09:18:25.812 30141 31597 D TSLocationManager: [c.t.l.LocationService onLocation]
09-26 09:18:25.812 30141 31597 D TSLocationManager: ╔═════════════════════════════════════════════
09-26 09:18:25.812 30141 31597 D TSLocationManager: ║ LocationService: location:1005
09-26 09:18:25.812 30141 31597 D TSLocationManager: ╠═════════════════════════════════════════════
09-26 09:18:25.812 30141 31597 D TSLocationManager: ╟─ 📍  Location[fused 45.519294,-73.616974 hAcc=19 et=+13d3h28m2s879ms vAcc=??? sAcc=??? bAcc=???], age: 133ms
09-26 09:18:25.832 30141 31597 I TSLocationManager: [c.t.l.l.TSLocationManager onSingleLocationResult]
09-26 09:18:25.832 30141 31597 I TSLocationManager:   🔵  Acquired current position
christocracy commented 6 years ago

On click of a button I need to get address by using latitude and longitude by making use of background geolocation am getting lat and long

I'm not concerned with what you need to do with the location. I want to see your code.

christocracy commented 6 years ago

And yes, if you execute #getCurrentPosition while indoors, it will take longer to fetch the location since GPS isn't available indoors. If the plugin fetches a high accuracy location (eg: <= 10 meters), it will immediately stop sampling and return that location immediately.

ReemaBegum commented 6 years ago

Right now am using this here is my code . Do I need to do any changes in configure options ? bgGeo.configure(callbackFn, failureFn, { desiredAccuracy: 0, stationaryRadius: 0, distanceFilter: 0, useSignificantChangesOnly: true, debug: false, stopOnTerminate: true, startOnBoot: false, stopTimeout: 1, stopDetectionDelay:0 } ) function callbackFn(location) { var coords = location.coords; var lat = coords.latitude; var lng = coords.longitude; }

christocracy commented 6 years ago

Please learn to format code. Right below the textarea i'm writing in is a link Styling with Markdown is supported.

Wrap code with 3-backticks

christocracy commented 6 years ago

Just edit your previous post.

ReemaBegum commented 6 years ago

When I open application in android it showing "License validation failure background geolocation running in evaluation mode " . We have purchased the license for this do I need to do any changes in config file ?

ReemaBegum commented 6 years ago

As you suggested to use #getCurrentPosition is there any parameter to specify time limit ?

christocracy commented 6 years ago

This issue is related to "Delay in getting Location".

Customers shouldn't use this public repo (it contains only latest stable release. Customers are granted access to a private repo for latest updates.

christocracy commented 6 years ago

Are you reading the docs for #getCurrentPosition?

ReemaBegum commented 6 years ago

Yes, we are using private repo

christocracy commented 6 years ago

Then why are you posting issues to the public repo?