1

I have been trying to integrate the transistorsoft background-fetch library without success: https://github.com/transistorsoft/react-native-background-fetch

When I chain any method to the BackgroundFetch component I get the error (attached in this post)

import BackgroundFetch from "react-native-background-fetch";

class TimerScreen extends React.Component {

...

componentDidMount() {

    this.configureBackgroundFetch();

}
...
configureBackgroundFetch() {
    // Configure BackgroundFetch.
    BackgroundFetch.configure({
      minimumFetchInterval: 15, // <-- minutes (15 is minimum allowed)
      stopOnTerminate: false, // <-- Android-only,
      startOnBoot: true, // <-- Android-only
      enableHeadless: true
    }, async () => {
      console.log('BackgroundFetch has started');
      BackgroundFetch.finish(BackgroundFetch.FETCH_RESULT_NEW_DATA);
    }, (error) => {
      console.log('RNBackgroundFetch failed to start')
    });
}
...

I haven't been able to find out why the library isn't working. I have used react native link and installed it in package.json

 ...
 {
       ...
       "react-native-background-fetch": "^2.5.3",
       ...
 }
 ...
Kacey Okafor
  • 43
  • 1
  • 9

1 Answers1

0

The problem was caused by Expokit not being configured correctly to use native modules. I made a bare React Native app and the library worked without returning an error.

Kacey Okafor
  • 43
  • 1
  • 9