transistorsoft / flutter_background_geolocation

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

Use geofence onEntry event in terminated mode #816

Closed MuhammadEhsanMirzaei closed 3 months ago

MuhammadEhsanMirzaei commented 2 years ago

Does this package save geofence onEnter in the database when the app is terminated? Is there any way to save on entry when the app is terminated and use it when opening the app or use it in the background to send an event to the server?

christocracy commented 2 years ago

when the app is terminated and use it when opening the app or

The persists each geofence event in its SQLite database.

If you’ve configured a Config.url, the plugin will automatically post each event to your server, regardless if terminated.

see api docs “HTTP Guide”

christocracy commented 2 years ago

Also see api docs Config.enableHeadless

MuhammadEhsanMirzaei commented 2 years ago

I found this in the document: [PERSIST_MODE_ALL] | (DEFAULT) Persist both geofence and location events But that didn't work. Do I set this persistMode: 2? That didn't work too

christocracy commented 2 years ago

Show me the Config you supplied to .ready(), which was requested in the issue template that you ignored

MuhammadEhsanMirzaei commented 2 years ago
bg.BackgroundGeolocation.ready(
      bg.Config(
        pausesLocationUpdatesAutomatically: false,
        disableLocationAuthorizationAlert: true,
        reset: true,
        stopOnStationary: false,
        stopTimeout: 0,
        stopAfterElapsedMinutes: 0,
        desiredAccuracy: bg.Config.DESIRED_ACCURACY_NAVIGATION,
        distanceFilter: 100,
        stopOnTerminate: false,
        startOnBoot: true,
        debug: true,
        persistMode: 2,
        logLevel: bg.Config.LOG_LEVEL_VERBOSE,
      ),
    ).then((bg.State state) {
      if (!state.enabled) {
        bg.BackgroundGeolocation.start();
      }
    });
christocracy commented 2 years ago

Since you’ve not provided an url in your Config, each event is still available to you in the plug-in’s SQLite db. See api docs BackgroundGeolocation.locations.

Also, why did you do this?

stopAfterElapsedMinutes: 0,

That means “.stop() after elapsed minutes".

if you don’t know exactly what that does, don’t configure it.

MuhammadEhsanMirzaei commented 2 years ago

I set stopAfterElapsedMinutes: 0 because I manually stop the background. For checking the database, I used this code String log = await bg.Logger.getLog(bg.SQLQuery( start: DateTime.parse('2022-08-22 16:25'), end: DateTime.now())); But geofence in terminated mode didn't record.

christocracy commented 2 years ago

because I manually stop the background.

delete that Config option.

github-actions[bot] commented 3 months ago

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

github-actions[bot] commented 3 months ago

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