Task Manager for updating location in the background.

Please provide the following:

  1. SDK Version: 38.0.0
  2. Platforms(Android/iOS/web/all): Android

My application keeps crashing whenever I try to open it for the second time. It works the first time I open the app. I have defined task manager globally in app.js like this:

console.log(‘task log’, TaskManager.isTaskDefined(‘background-location-task’));
if (!TaskManager.isTaskDefined(‘background-location-task’)) {
TaskManager.defineTask(‘background-location-task’, async ({ data, error }) => {
if (error) {
if (data) {
const { locations } = data;
// console.log(‘location is’, locations);
const client = await getLoginClient();
.post(‘cook/lat-long’, {
current_lat: locations[locations.length - 1].coords.latitude,
current_long: locations[locations.length - 1].coords.longitude,
.then((response) => {
console.log(‘Posted’, response);
.catch((error) => {
console.log(‘Error is’, error);

and then I reference this task in the initial screen after login like this:
componentDidMount = async () => {
await Location.startLocationUpdatesAsync(‘background-location-task’, {
accuracy: Location.Accuracy.lowest,
timeInterval: 1800000,

Hey @karanbalodi1,

Can you share a public repo that has the relevant code to cause the crash so we can test it on our end?


This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.