Closed jamalalisubhani closed 7 months ago
if the actual fetch event fires and BackgroundGeolocation.getCurrentPosition
returns a location, then the plugins' job is complete.
I suggest you provide BackgroundGeolocation
an url
to your server and let is pure-native HTTP service handle uploading to your server.
@christocracy I am making POST api call using axios in react native ios app, its not making any api call, how can i test that?
I have no experience with Axios. I have no need for it. The plug-in has its own built-in native http service which does not have problems running in the background. Apparently this "Axios" has problems.
If you want to use Axios for http, seek support with them.
@christocracy thanks for the solution it worked with pure-native HTTP service handle uploading to my server.
Background-fetch for updating location in background app is in killed state:
service.ts
import BackgroundFetch from 'react-native-background-fetch'; import BackgroundGeolocation from 'react-native-background-geolocation'; import { UpdateUserData } from './general.service'; import { store } from '../redux/store'; import { setAuthToken, setUser } from '../redux/reducers/userReducers';
const configureBackgroundFetch = async () => {
// Configure background fetch BackgroundFetch.configure( { minimumFetchInterval: 15, // Minimum fetch interval in minutes (e.g., 15 minutes) stopOnTerminate: false, // Continue running background fetch when the app is terminated startOnBoot: true, // Start background fetch on device boot enableHeadless: true, // Enable headless mode for background task requiresDeviceIdle: false, // Set to true to require the device to be idle forceAlarmManager: false, // Android-only: use AlarmManager instead of JobScheduler }, async (taskId) => { console.log('[BackgroundFetch] Received event:', taskId);
BackgroundGeolocation.start();
// Start the background fetch service BackgroundFetch.start();
// Configure and start BackgroundGeolocation BackgroundGeolocation.ready({ desiredAccuracy: BackgroundGeolocation.DESIRED_ACCURACY_HIGH, distanceFilter: 1, stopTimeout: 50000, debug: true, logLevel: BackgroundGeolocation.LOG_LEVEL_VERBOSE, stopOnTerminate: false, startOnBoot: true, }).then((state) => { console.log('- BackgroundGeolocation is configured and ready:', state);
});
BackgroundGeolocation.getCurrentPosition({ timeout: 30, maximumAge: 5000, desiredAccuracy: 1, }) .then((res) => { console.log('Location data:', res.coords.latitude, res.coords.longitude);
};
export default configureBackgroundFetch;
This file is fetching background location but not calling the api for updating it in ios, what could be the possible reason, i have followed all the steps mentioned in package documnetation for configuration.