SDK 37.0 | TaskManager keeps saying task is not defined despite being already defined

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

I have a simple code where it will log “Hello” if BackgroundFetch starts working
But whenever BackgroundFetch.registerTaskAsync tries to run, it will always say that the task is undefined despite being defined already before it mounts

Is there a solution?

// TaskScreen.js
const TASK_NAME = "get one"

TaskManager.defineTask(TASK_NAME, () => {
    try {
      const receivedNewData = 10
      console.log("Hello")
      return receivedNewData ? BackgroundFetch.Result.NewData : BackgroundFetch.Result.NoData;
    } catch (error) {
      return BackgroundFetch.Result.Failed;
    }
  });


export default function TaskScreen() {
    useEffect(() => {
        BackgroundFetch.registerTaskAsync(TASK_NAME, {minimumInterval: 5, stopOnTerminate: false, startOnBoot: true})
    }, [])

    return (
        <View style={styles.screen}>
            <Button title="Click" onPress={() => {
                console.log("pressed")
                
            }}/>
        </View>
    )
}

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