后台获取:无法读取未定义的属性“配置”

时间:2019-04-24 20:30:52

标签: react-native background-fetch

我一直在尝试集成晶体管软后台获取库,但没有成功: https://github.com/transistorsoft/react-native-background-fetch

当我将任何方法链接到BackgroundFetch组件时,都会收到错误消息(在本文中附上)

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')
    });
}
...

我无法找出为什么图书馆没有工作。我已经使用了react native链接并将其安装在package.json

 ...
 {
       ...
       "react-native-background-fetch": "^2.5.3",
       ...
 }
 ...

1 个答案:

答案 0 :(得分:0)

该问题是由于未正确配置Expokit来使用本机模块而引起的。我制作了一个简单的React Native应用程序,该库正常运行而没有返回错误。