transistorsoft / flutter_background_geolocation

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

Events are not invoked once app is running in background for long #241

Closed satenk closed 4 years ago

satenk commented 4 years ago

Your Environment

Expected Behavior

All the events implementation should be correct geofence exit, geofence enter, stationary exit, heartbeat in 15 minute. As its part of requirement

Actual Behavior

Events are not invoked once app is running in background for long

Steps to Reproduce

1. 2. 3. 4.

Context

we are trying to get any event and send the lat and long to backend using Custom APIs (We dont mind using any existing way if suggested by you)

Debug logs

Logs PASTE_YOUR_LOGS_HERE [Archive.zip](https://github.com/transistorsoft/flutter_background_geolocation/files/4503534/Archive.zip)
christocracy commented 4 years ago

I need logs and specific timestamps within those logs that are interesting to you.

satenk commented 4 years ago

background-geolocation (4).log

19-4-2020 around 7:30 am exit 20-4-2020 around 7:18 am exit I want to perform HTTP request at Exit stationary region where will i get this event?

christocracy commented 4 years ago

Try installing and field-testing branch geofencing.

dependencies:
  flutter_background_geolocation:
    git:
      url: https://github.com/transistorsoft/flutter_background_geolocation.git
      ref: geofencing
christocracy commented 4 years ago

I want to perform HTTP request at Exit stationary region where will i get this event?

See API docs BackgroundGeolocation.onMotionChange

satenk commented 4 years ago

dear Chris,

BackgroundGeolocation.onMotionChange does not fire exactly on Exit stationary region but it fires if the person is moving in vehicle or foot.

our requirement is simple and we need your support.

we need to call your HTTP API on same time when we get Exit stationary region (alert) in app.

christocracy commented 4 years ago

BackgroundGeolocation.onMotionChange does not fire exactly on Exit stationary region but it fires if the person is moving in vehicle or foot.

When an iOS device moves about 200 meters from last known location, the the plugin turns on location-services, fires the onMotionChange event and begins tracking the location.

we need to call your HTTP API on same time when we get Exit stationary region (alert) in app.

If you've configured the plugin with an url, the plugin will automatically post the motionchange location to to your server. You don't need to anything to make this happen (other than configuring autoSync: true.

satenk commented 4 years ago

Plugins getting stopped after few hours and start again automatically after more that 20 hours. please see the attached logs generated in iPhone 6s running 13.5 and iPad 6th gen 13.3

{ activityRecognitionInterval = 10000; activityType = 1; authorization = { }; autoSync = 1; autoSyncThreshold = 0; batchSync = 0; debug = 1; desiredAccuracy = "-1"; desiredOdometerAccuracy = 100; didLaunchInBackground = 1; disableAutoSyncOnCellular = 0; disableElasticity = 0; disableLocationAuthorizationAlert = 0; disableMotionActivityUpdates = 0; disableStopDetection = 0; distanceFilter = 100; elasticityMultiplier = 1; enableTimestampMeta = 0; enabled = 1; encrypt = 0; extras = { }; geofenceInitialTriggerEntry = 1; geofenceProximityRadius = 2000; geofenceTemplate = ""; headers = { Authorization = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI1ZTg4NzkyMDQ4YTVmYjMwNThlN2U1YTMiLCJ1c2VybmFtZSI6Ijk4MDE5MDQ3Iiwicm9sZSI6IlVTRVIiLCJuYW1lIjoic2F0ZW4iLCJwaG9uZU51bWJlciI6Ijk4MDE5MDQ3IiwiaWF0IjoxNTkwMzAyODM2fQ.2slqy3Ui9bjts3NHhXAqfOwwHNA7e33KJKXBjsOCeQQ"; }; heartbeatInterval = 1800; httpRootProperty = location; httpTimeout = 60000; iOSHasWarnedLocationServicesOff = 1; isFirstBoot = 0; isMoving = 0; lastLocationAuthorizationStatus = 3; locationAuthorizationAlert = { cancelButton = Cancel; instructions = "You must enable 'Always' in location-services"; settingsButton = Settings; titleWhenNotEnabled = "location-services not enabled"; titleWhenOff = "location-services OFF"; }; locationAuthorizationRequest = Always; locationTemplate = ""; locationTimeout = 60; locationsOrderDirection = ASC; logLevel = 5; logMaxDays = 3; maxBatchSize = "-1"; maxDaysToPersist = 1; maxRecordsToPersist = "-1"; method = POST; minimumActivityRecognitionConfidence = 70; odometer = 0; params = { "always_location" = "PermissionStatus.granted"; "location_status" = "PermissionStatus.granted"; "when_in_use_location" = "PermissionStatus.granted"; }; pausesLocationUpdatesAutomatically = 0; persistMode = 2; preventSuspend = 1; schedule = ( ); schedulerEnabled = 0; showsBackgroundLocationIndicator = 0; startOnBoot = 1; stationaryRadius = 25; stopAfterElapsedMinutes = "-1"; stopDetectionDelay = 0; stopOnStationary = 0; stopOnTerminate = 0; stopTimeout = 5; trackingMode = 0; url = "http://134.209.106.231:3000/api/v1/user/location/dump-logs"; useSignificantChangesOnly = 0; } background-geolocation.log background-geolocation-2.log

christocracy commented 4 years ago

Please always syntax-highlight your code by wrapping in triple backticks:

satenk commented 4 years ago
bg.BackgroundGeolocation.ready(bg.Config(
            locationAuthorizationAlert: {
              'titleWhenNotEnabled': 'location-services not enabled',
              'titleWhenOff': 'location-services OFF',
              'instructions': 'You must enable \'Always\' in location-services',
              'cancelButton': 'Cancel',
              'settingsButton': 'Settings'
            },
            desiredAccuracy: bg.Config.DESIRED_ACCURACY_HIGH,
            distanceFilter: 100,
            stopOnTerminate: false,
            enableHeadless: true,
            foregroundService: true,
            heartbeatInterval: 60 * 30,
            preventSuspend: true,
            notificationText: "Stay Safe!",
            headers: {'Authorization': token},
            params: {
              'location_status': location.toString(),
              'always_location': alwaysAllowStatus.toString(),
              'when_in_use_location': whenInUseStatus.toString(),
            },
            url: 'http://134.209.106.231:3000/api/v1/user/location/dump-logs',
            geofenceModeHighAccuracy: true,
            locationAuthorizationRequest: "Always",
            startOnBoot: true,
            useSignificantChangesOnly: false,
            debug: true,
            logMaxDays: 3,
            logLevel: bg.Config.LOG_LEVEL_VERBOSE))
        .then((bg.State state) {
      if (!state.enabled) {
        print('BackgroundGeolocation.start called');
        bg.BackgroundGeolocation.start();
      }
    });
satenk commented 4 years ago

This is what is written in the mail which i'm receiving from logger

{
activityRecognitionInterval = 10000;
activityType = 1;
authorization = {
};
autoSync = 1;
autoSyncThreshold = 0;
batchSync = 0;
debug = 1;
desiredAccuracy = "-1";
desiredOdometerAccuracy = 100;
didLaunchInBackground = 1;
disableAutoSyncOnCellular = 0;
disableElasticity = 0;
disableLocationAuthorizationAlert = 0;
disableMotionActivityUpdates = 0;
disableStopDetection = 0;
distanceFilter = 100;
elasticityMultiplier = 1;
enableTimestampMeta = 0;
enabled = 1;
encrypt = 0;
extras = {
};
geofenceInitialTriggerEntry = 1;
geofenceProximityRadius = 2000;
geofenceTemplate = "";
headers = {
Authorization = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI1ZTg4NzkyMDQ4YTVmYjMwNThlN2U1YTMiLCJ1c2VybmFtZSI6Ijk4MDE5MDQ3Iiwicm9sZSI6IlVTRVIiLCJuYW1lIjoic2F0ZW4iLCJwaG9uZU51bWJlciI6Ijk4MDE5MDQ3IiwiaWF0IjoxNTkwMzAyODM2fQ.2slqy3Ui9bjts3NHhXAqfOwwHNA7e33KJKXBjsOCeQQ";
};
heartbeatInterval = 1800;
httpRootProperty = location;
httpTimeout = 60000;
iOSHasWarnedLocationServicesOff = 1;
isFirstBoot = 0;
isMoving = 0;
lastLocationAuthorizationStatus = 3;
locationAuthorizationAlert = {
cancelButton = Cancel;
instructions = "You must enable 'Always' in location-services";
settingsButton = Settings;
titleWhenNotEnabled = "location-services not enabled";
titleWhenOff = "location-services OFF";
};
locationAuthorizationRequest = Always;
locationTemplate = "";
locationTimeout = 60;
locationsOrderDirection = ASC;
logLevel = 5;
logMaxDays = 3;
maxBatchSize = "-1";
maxDaysToPersist = 1;
maxRecordsToPersist = "-1";
method = POST;
minimumActivityRecognitionConfidence = 70;
odometer = 0;
params = {
"always_location" = "PermissionStatus.granted";
"location_status" = "PermissionStatus.granted";
"when_in_use_location" = "PermissionStatus.granted";
};
pausesLocationUpdatesAutomatically = 0;
persistMode = 2;
preventSuspend = 1;
schedule = (
);
schedulerEnabled = 0;
showsBackgroundLocationIndicator = 0;
startOnBoot = 1;
stationaryRadius = 25;
stopAfterElapsedMinutes = "-1";
stopDetectionDelay = 0;
stopOnStationary = 0;
stopOnTerminate = 0;
stopTimeout = 5;
trackingMode = 0;
url = "http://134.209.106.231:3000/api/v1/user/location/dump-logs";
useSignificantChangesOnly = 0;
}
christocracy commented 4 years ago

Your iOS app will be terminated while sitting suspended in the background at some point.

When the device begins moving, iOS will relaunch your app in the background and tracking will resume.

satenk commented 4 years ago

Out requirement is that the plugin must not stop in any situation. It must work. at least heartbeat event must occur if there is no movement and the app is idle. because it's getting stopped for more than 24 hours even with movement. It will be very helpful if you can make some change in the plugin based on our requirement. we are ready to pay for your development fee. background-geolocation-4.log

christocracy commented 4 years ago

Your requirement is impossible.

You must assume that your app will be terminated while the device is sitting stationary and your app suspended in the background.

With mobile development, “You can’t always get what you want”, particularly with iOS.

You must adjust your requirements.

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. You may also mark this issue as a "discussion" and I will leave this open.

stale[bot] commented 4 years ago

Closing this issue after a prolonged period of inactivity. Fell free to reopen this issue, if this still affecting you.