undefined _ExpoTaskManager.default.EVENT_Name

Hello. I’m trying to implement the new feature “TaskManager” to get the location of device in the background. My code is very similar to the one in the docs, but when I run the code, I get the following error: "undefined is not an object (evaluating ‘_ExpoTaskManager.default.EVENT_NAME’).
Can you help me with this? I need a solution as quickly as possible.
I try to run this on an android device with Expo. Thank you !

import React from 'react';
import { Location, TaskManager } from 'expo';
import { Text, Button } from 'react-native';

const LOCATION_TASK_NAME = 'background-location-task';

export default class Component extends React.Component {
  onPress = async () => {
    await Location.startLocationUpdatesAsync(LOCATION_TASK_NAME, {
      accuracy: Location.Accuracy.Balanced,
    });
  };

  render() {
    return (
      <Button onPress={this.onPress}>
        <Text>Enable background location</Text>
      </Button>
    );
  }
}

TaskManager.defineTask(LOCATION_TASK_NAME, ({ data, error }) => {
  if (error) {
    // Error occurred - check `error.message` for more details.
    return;
  }
  if (data) {
    const { locations } = data;
    // do something with the locations captured in the background
  }
});

I have the same issue.
I solved this by changing the app.json.
from “sdkVersion”: “31.0.0”,
to “sdkVersion”: “32.0.0”,
then it worked.

2 Likes

I solved this issue today. I changed the version in app.json. Thanks anyway!

1 Like

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