transistorsoft / capacitor-background-geolocation

The most sophisticated background location-tracking & geofencing module with battery-conscious motion-detection intelligence for iOS and Android.
MIT License
93 stars 16 forks source link

The plugin works at the start and stops working after time (day or more) #278

Open dvirLevi opened 2 days ago

dvirLevi commented 2 days ago

Your Environment

Expected Behavior

Expect the plugin to work continuously forever

Actual Behavior

The plugin sends a location to the server for a day or so but after that it stops sending locations even when the device is moved

Steps to Reproduce

  1. Config plugin using .ready
  2. start plugin by calling initialBackgroundGeolocation()

    
    return new Promise(async (resolve, reject) => {
    const state = await BackgroundGeolocation.ready({
      locationAuthorizationRequest: 'Always',
      desiredAccuracy: BackgroundGeolocation.DESIRED_ACCURACY_HIGH,
      distanceFilter: 1,
      stopTimeout: 1,
      isMoving: true,
      debug: false,
      logLevel: BackgroundGeolocation.LOG_LEVEL_VERBOSE,
      stopOnTerminate: false,
      startOnBoot: true,
      backgroundPermissionRationale: {
        title: 'אפשר ל {applicationName} לגשת למיקום ברקע',
        message: `אפשר 'כן, כל הזמן'.
        כמובן שזה לא חתונה, ותמיד אפשר לשנות זאת.
        `,
        positiveAction: '{backgroundPermissionOptionLabel}',
        negativeAction: ''
      },
      url: server + '/app/locations',
      batchSync: false,
      autoSync: true,
      headers: { 'Content-Type': 'application/json' },
      params: {
        id: identifyId
      }
    })
    if (!state.enabled) {
      // BackgroundGeolocation.start(function () {
      //   console.log('- Start success')
      //   resolve()
      // })
      BackgroundGeolocation.start().then((state) => {
        console.log('[start] success - ', state)
        resolve()
      })
    }
    
    const interval = setInterval(async () => {
      const permission = await requestPermission()
      if (permission !== 4) clearInterval(interval)
    }, 10000)
    })
    } ```

Context

Debug logs

Logs ``` PASTE_YOUR_LOGS_HERE ```
christocracy commented 2 days ago

Sounds like a case of https://dontkillmyapp.com

stopTimeout: 1,

Unrelated, but your stopTimeout is far too low. That’s going to trigger at red lights.

christocracy commented 2 days ago

Also, see wiki “Debugging”. When something unusual happens, set debug: true and fetch the logs using .emailLog

dvirLevi commented 2 days ago

Sounds like a case of https://dontkillmyapp.com

stopTimeout: 1,

Unrelated, but your stopTimeout is far too low. That’s going to trigger at red lights.

What is the recommended value for stopTimeout?

christocracy commented 2 days ago

>= 5