react-native-background-geolocation icon indicating copy to clipboard operation
react-native-background-geolocation copied to clipboard

Continues Geolocation in background not working in android

Open YogendraMLIM opened this issue 3 years ago • 1 comments

Your Environment

  • Plugin version:4.9.3

  • Platform: Android

  • OS version:11

  • Device manufacturer / model: IN_2b Micromax

  • React Native version (react-native -v):0.68.2

  • Plugin config BackgroundGeolocation.setConfig({ distanceFilter: 0, url: "http://*********************/locations" });

    BackgroundGeolocation.reset({ debug: false, logLevel: BackgroundGeolocation.LOG_LEVEL_VERBOSE, desiredAccuracy: BackgroundGeolocation.DESIRED_ACCURACY_HIGH, distanceFilter: 50, disableElasticity: false, locationUpdateInterval: 1000, fastestLocationUpdateInterval: -1, stopTimeout: 1, motionTriggerDelay: 30000, backgroundPermissionRationale: { title: "Allow {applicationName} to access this device's location even when closed or not in use.", message: "This app collects location data to enable recording your trips to work and calculate distance-travelled.", positiveAction: 'Change to "{backgroundPermissionOptionLabel}"', negativeAction: 'Cancel' }, schedule: [ '2-6 09:00-17:00' ], scheduleUseAlarmManager: true, maxDaysToPersist: 14, geofenceModeHighAccuracy: true, stopOnTerminate: false, startOnBoot: true, enableHeadless: true, heartbeatInterval: -1 });

    BackgroundGeolocation.ready({ // Geolocation Config distanceFilter: 0, locationAuthorizationRequest: 'Always', // Activity Recognition stopTimeout: 1, debug: false, // <-- enable this hear sounds for background-geolocation life-cycle. persistMode: BackgroundGeolocation.PERSIST_MODE_ALL, logLevel: BackgroundGeolocation.LOG_LEVEL_VERBOSE, reset: true, foregroundService: true, enableHeadless: true, // preventSuspend: true, stopDetectionDelay: 10000, heartbeatInterval: 30, locationUpdateInterval: 10000, // Default: 1000. With distanceFilter: 0, Sets the desired interval for location updates, in milliseconds. This setting will be ignored when distanceFilter > 0 fastestLocationUpdateInterval: 10000, //Default: 10000. Explicitly set the fastest interval for location updates, in milliseconds. geofenceModeHighAccuracy: true, // <-- Runs startGeofences with a foreground service (along with its corresponding persitent Notification). This will make geofence triggering far more consistent at the expense of higher power usage. geofenceProximityRadius: 10, // <-- Default: 1000. Radius in meters to query for geofences within proximity. disableMotionActivityUpdates: true, useSignificantChangesOnly: false, triggerActivities: 'in_vehicle, on_bicycle, running, walking, on_foot', forceReloadOnBoot: true, //Force launch your terminated App after a device reboot or application update. locationAuthorizationAlert: { titleWhenNotEnabled: "Location service is not configured correctly", titleWhenOff: "Location service is not enabled", instructions: 'You must set your location to "always" for Aptimiz to work properly', cancelButton: 'Cancel', settingsButton: 'Parameters', }, backgroundPermissionRationale: { title: 'Allow {applicationName} to access your location in the background?', message: "This app collects location information to help measure your working time even when the app is closed or not in use. Information collection will stop if you turn off the app button.", positiveAction: 'Change to {backgroundPermissionOptionLabel}', negativeAction: 'Cancel', }, notification: { title: "Geo Fencing", text: 'You are online!.', largeIcon: 'mipmap-xxxhdpi/ic_launcher.png', smallIcon: 'mipmap-hdpi/ic_launcher.png', }, schedule: ["2-6 09:00-17:00"], scheduleUseAlarmManager: true, // schedule: [ // "1 17:30-21:00", // Sunday: 5:30pm-9:00pm // "2-6 9:00-17:00", // Mon-Fri: 9:00am to 5:00pm // "2,4,6 20:00-00:00",// Mon, Web, Fri: 8pm to midnight (next day) // "7 10:00-19:00" // Sat: 10am-7pm // ], autoSync: true, desiredAccuracy: BackgroundGeolocation.DESIRED_ACCURACY_HIGH, stopOnTerminate: false, // <-- Allow the background-service to continue tracking when user closes the app. startOnBoot: true, // <-- Auto start tracking when device is powered-up. url: "http://ccil.mlinfomap.asia/ccil/Api/locations", params: { "user_id": 123 }, headers: { "my-auth-token": "secret-key" }, showsBackgroundLocationIndicator: true }, function (state) { if (!state.enabled) { setTimeout(() => { BackgroundGeolocation.start((state) => { console.log('state.enabled'); //console.log(state.enabled); }).catch((err) => { console.log('error', err) }); BackgroundGeolocation.startSchedule();

      }, 5000)
    }
    

    });

    BackgroundGeolocation.onSchedule((state) => { let enabled = state.enabled; console.log("[onSchedule] - enabled? ", enabled); });

Expected Behavior

Continues (on given interval) Geolocation in background should be sync to server either in foreground or when user terminate or clear app.

Actual Behavior

Continues Geolocation in background not working in Android when user terminate or clear app, Geolocation automatically working after some random duration, we need geolocation in background on given interval.

Steps to Reproduce

1.Install app 2.Give all permission 3.Close or terminate the app 4.

Context

I just terminate/ close the app

Debug logs

Logs
PASTE_YOUR_LOGS_HERE

YogendraMLIM avatar Dec 08 '22 08:12 YogendraMLIM

I suggest you fetch the plugin logs when something unusual happens. See wiki Debugging.

also see https://dontkillmyapp.com

christocracy avatar Dec 08 '22 14:12 christocracy

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

github-actions[bot] avatar Jun 04 '24 01:06 github-actions[bot]

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

github-actions[bot] avatar Jun 18 '24 01:06 github-actions[bot]