Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

location tracking only works when the app is in the foreground, with no updates in the background #2191

Open
Bharatkt opened this issue Oct 28, 2024 · 3 comments

Comments

@Bharatkt
Copy link

Bharatkt commented Oct 28, 2024

Your Environment

  • Plugin version: 4.17.4
  • Platform: Android
  • OS version: Android 13
  • Device manufacturer / model: Realme RMX3501
  • React Native version (react-native -v): 0.72.2
  • Plugin config
BackgroundGeolocation.ready({
        enableHeadless: true,
        desiredAccuracy: BackgroundGeolocation.DESIRED_ACCURACY_HIGH,
        // Android Call api after certain period
        distanceFilter: 0,
        locationUpdateInterval: 1 * 60 * 1000, // 5 minutes        stopTimeout: 5,

        locationAuthorizationRequest: 'Always',
        backgroundPermissionRationale: {
          message:
            'App provides address verification for banking. We use background location access to collect geotags, ensuring accurate address verification',
          title: `Allow App to access this device's location.`,
          positiveAction: 'Change to "{backgroundPermissionOptionLabel}"',
          negativeAction: 'Cancel',
        },

        // iOS notifications from taskbar
        showsBackgroundLocationIndicator: false,

        // physical activity permission disbale
        disableMotionActivityUpdates: true,

        // Sounds / Notification
        debug: false,

        // Logs
        logLevel: BackgroundGeolocation.LOG_LEVEL_VERBOSE,

        // Android options for get location on BG
        stopOnTerminate: false,
        startOnBoot: true,

        // // HTTP / SQLite config
        // url: '<ENV_URL>/user/location',
        // batchSync: false, // <-- [Default: false] Set true to sync locations to server in a single HTTP request.
        // autoSync: true, // <-- [Default: true] Set true to sync each location to server as it arrives.
        // headers: {
        //   Authorization: `Bearer ${token}`,
        //   'Content-Type': 'application/json',
        // },
        // Filter out old timestamps
        // maxRecordsToPersist: 10, // Limit the number of records to keep
        // autoSyncThreshold: 1, // Sync every location
      }).then(state => {
        BackgroundGeolocation.onLocation(async location => {
          await sendLocationToServer(location);
          console.warn(location);
        });
        BackgroundGeolocation.start();
      });

Expected Behavior

The background location tracking feature was working as expected before this issue began.

Actual Behavior

Background location tracking is not functioning; only foreground location updates are being received.

Steps to Reproduce

  1. Verified that location permissions are correctly set
    2.Confirmed no recent changes to the location-related code
  2. Restarted both the app and device, but the issue remains unresolved.

Context

Debug logs

Logs
PASTE_YOUR_LOGS_HERE
@christocracy
Copy link
Member

Realme RMX3501

See https://dontkillmyapp.com

disableMotionActivityUpdates: true,

Without the Motion API to determine when the device is moving, you are relying only upon a geofence around the last known position to determine when the device is moving.

Why are you disabling the Motion API? You'll have much better performance if you don't disable that.

@Bharatkt
Copy link
Author

Hello @christocracy I have enable the Motion API, and Testing still not working, we can't change anything in code for BackgroundGeolocation file since last 2 month and it's working fine before, Is there any way to debug ?

@christocracy
Copy link
Member

Logs. I need logs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants