transistorsoft / flutter_background_geolocation

Sophisticated, battery-conscious background-geolocation & geofencing with motion-detection
https://www.transistorsoft.com/shop/products/flutter-background-geolocation
Other
650 stars 241 forks source link

im unable to get location using this method , when i install the apk its give one time location after that its not work, #1371

Closed arslancs closed 3 weeks ago

arslancs commented 3 weeks ago

Your Environment

Expected Behavior

i need to location on after every specific time or interval ,

Actual Behavior

when i call onLocation method first time on installing the apk it give me location perfectly but after that it failed to give me update

Steps to Reproduce

1. 2. 3. 4.

Context

Debug logs

I/TSLocationManager(28697): β•Ÿβ”€ πŸ“ Location[fused 31.493771,74.417442 hAcc=15.043 et=+13d16h29m18s197ms alt=195.10000610351562 vAcc=1.0], time: 1730113515566 I/TSLocationManager(28697): [c.t.l.d.s.SQLiteLocationDAO persist] I/TSLocationManager(28697): βœ… INSERT: d29176f3-7791-4774-baa2-574268285676 D/TSLocationManager(28697): [c.t.l.g.TSGeofenceManager startMonitoringStationaryRegion] D/TSLocationManager(28697): 🎾 Start monitoring stationary region (radius: 150.0m 31.4937708,74.4174417 hAcc=15.043) I/TSLocationManager(28697): [c.t.l.l.TSLocationManager onSingleLocationResult] I/TSLocationManager(28697): πŸ”΅ Acquired motionchange position, isMoving: false D/TSLocationManager(28697): [c.t.l.l.TSLocationManager a] Median accuracy: 14.037001 D/TSLocationManager(28697): [c.t.l.service.AbstractService a] D/TSLocationManager(28697): βš™οΈοΈŽ FINISH [LocationRequestService startId: 4, eventCount: 0, sticky: false] I/flutter (28697): Location emitted: Latitude: 31.4937708, Longitude: 74.4174417 I/TSLocationManager(28697): [c.t.l.d.s.SQLiteLocationDAO persist] I/TSLocationManager(28697): βœ… INSERT: f2b0f873-ef90-4a17-b872-d574f1924d82 D/TSLocationManager(28697): [c.t.l.g.TSGeofenceManager startMonitoringStationaryRegion] D/TSLocationManager(28697): 🎾 Start monitoring stationary region (radius: 150.0m 31.4937708,74.4174417 hAcc=15.043) D/TSLocationManager(28697): [c.t.l.service.AbstractService b] D/TSLocationManager(28697): 🎾 STOP [LocationRequestService startId: 6, eventCount: 1] D/TSLocationManager(28697): [c.t.l.service.AbstractService a] D/TSLocationManager(28697): βš™οΈοΈŽ FINISH [LocationRequestService startId: 6, eventCount: 0, sticky: false] I/flutter (28697): Location emitted: Latitude: 31.4937708, Longitude: 74.4174417 D/TSLocationManager(28697): [c.t.l.service.AbstractService a] D/TSLocationManager(28697): 🎾 motionchange [TrackingService startId: 1, eventCount: 1] I/TSLocationManager(28697): [c.t.l.service.TrackingService k] I/TSLocationManager(28697): ╔═════════════════════════════════════════════ I/TSLocationManager(28697): β•‘ TrackingService motionchange: false I/TSLocationManager(28697): ╠═════════════════════════════════════════════ D/TSLocationManager(28697): [c.t.l.service.AbstractService a] D/TSLocationManager(28697): βš™οΈοΈŽ FINISH [TrackingService startId: 1, eventCount: 0, sticky: false] D/TSLocationManager(28697): [c.t.l.service.AbstractService f] D/TSLocationManager(28697): βš™οΈοΈŽ LocationRequestService.stopSelfResult(6): true D/TSLocationManager(28697): [c.t.l.service.AbstractService onDestroy] D/TSLocationManager(28697): πŸ”΄ LocationRequestService stopped D/TSLocationManager(28697): [c.t.l.service.AbstractService f] D/TSLocationManager(28697): βš™οΈοΈŽ TrackingService.stopSelfResult(1): true D/TSLocationManager(28697): [c.t.l.service.AbstractService onDestroy] D/TSLocationManager(28697): πŸ”΄ TrackingService stopped ``` PASTE_YOUR_LOGS_HERE ```
christocracy commented 3 weeks ago

its give one time location after that its not work

That’s exactly what this plug-in is designed to do. Read the wiki β€œPhilosophy of Operation”.

then go outside and move at least 1000 meters.

arslancs commented 3 weeks ago

So there is no method or function that returns the location after some interval whether the user changes his location or not? @christocracy

christocracy commented 3 weeks ago

No. That’s what background-fetch is for (already included as a dependency and also created by Transistor Software):

https://github.com/transistorsoft/react-native-background-fetch

christocracy commented 3 weeks ago

This plugin is fully function in DEBUG builds so you can try before you buy, as noted at the top of the README

Screenshot 2024-10-28 at 9 29 41β€―AM
arslancs commented 3 weeks ago

@christocracy in debug why its showing license validation failed ?

christocracy commented 3 weeks ago

It's normal. Ignore it. As long as it's a DEBUG build, it's fully functional.

arslancs commented 3 weeks ago

this is my code , im getting location when close the app and open it , but in background im not getting location , but app showing getting location sign in background too! void _startBackgroundGeolocation() { bg.BackgroundGeolocation.onLocation((bg.Location location) { _connectSocketAndEmit(location.coords.latitude.toString(), location.coords.longitude.toString()); });

bg.BackgroundGeolocation.ready(bg.Config(
        desiredAccuracy: bg.Config.DESIRED_ACCURACY_HIGH,
        distanceFilter: 0,
        disableElasticity: true,
        stopOnTerminate: false,
        enableHeadless: true,
        startOnBoot: true,
        debug: true,
        logLevel: bg.Config.LOG_LEVEL_VERBOSE))
    .then((bg.State state) {
  if (!state.enabled) {
    bg.BackgroundGeolocation.start();
  }
});

}

arslancs commented 3 weeks ago

i need to test before buying it ! @christocracy

christocracy commented 3 weeks ago

but in background im not getting location

What makes you think that? Are you observing the plugin logs? See Wiki "Debugging". You should be observing the log stream:

$ adb logcat *:S TSLocationManager:V

The plugin is telling you everything it's doing in the logs.

christocracy commented 3 weeks ago

You should be hearing debug Sound FX. If you hear the soundFX, it's working.

arslancs commented 3 weeks ago

what do mean by plugin logs ? im hitting socket on location change method to get bg location updates , bg.BackgroundGeolocation.onLocation((bg.Location location) { _connectSocketAndEmit(location.coords.latitude.toString(), location.coords.longitude.toString()); }); so bg.BackgroundGeolocation.onLocation method will not perform callback in bg ? @christocracy

christocracy commented 3 weeks ago

what do mean by plugin logs ?

Ready the Wiki "Debugging". Learn to observe the plugin logs. This plugin has an incredibly verbose logging system that logs absolutely everything it's doing.

so bg.BackgroundGeolocation.onLocation method will not perform callback in bg

No, that's NOT true.

Are you confused about background vs terminated? They are two completely different states.

arslancs commented 3 weeks ago

@christocracy thanks got it , u mean it ll not work when app is terminated , if not then u must need to work on it to run when this when app is killed!

christocracy commented 3 weeks ago

u mean it ll not work when app is terminated

No, that's NOT what I mean. Why do you think the plugin contains the option stopOnTerminate: false?

Are you confused about background vs terminated?

Are you talking about the terminated OR background state?

arslancs commented 3 weeks ago

when app is terminated , its bg.BackgroundGeolocation.onLocation callback is not working, then how can i get logs of location when app is terminated ? what ll b use of stopOnTerminate: false etc!

christocracy commented 3 weeks ago

when app is terminated , its bg.BackgroundGeolocation.onLocation

For the Android terminated state, see API docs Config.enableHeadless

Your Flutter App instance (where your UI lives) no longer exists when an Android app is terminated.

So, no: .onLocation does NOT fire when the Android app is terminated. You need to register a "headless task", as described in the API docs linked above.

christocracy commented 3 weeks ago

background and terminated are two completely different Android App states.

arslancs commented 3 weeks ago

exactly what im saying! bg.BackgroundGeolocation.onLocation will not work when app is terminated! yes i know ,background and terminated state, thanks for clearing it!

christocracy commented 3 weeks ago

exactly what im saying!

No, that's not exactly what you've been saying. What you said is "but in background im not getting location".

background != terminated.

arslancs commented 3 weeks ago

thank you!