react-native - 背景提取:无法读取未定义的属性“配置”
问题描述
我一直在尝试集成transistorsoft 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",
...
}
...
解决方案
该问题是由于 Expokit 未正确配置为使用本机模块引起的。我制作了一个简单的 React Native 应用程序,并且该库可以正常工作而没有返回错误。
推荐阅读
- eclipse - 如何从 jBPM 中的流程图生成代码以在浏览器中进行测试?
- c++ - 从以下代码构造的对象的类型应该是什么,即 new TreeNode
(13) - apache-drill - Apache Drill:阵列的两个横向连接仅使用存储插件失败
- c++ - 犰狳 - 矩阵表达式中没有名为 i 的成员
- java - 我返回了一个数组,但是当我尝试复制该数组时,NetBeans 找不到该符号
- sql-server - SQL Server 2016 变更数据捕获 - 可否用于从源加载仓库暂存表?
- javascript - 无法联系recaptcha。检查您的连接,然后重试。初次提交后(reCaptcha v2 不可见)
- c++ - operator = problem. Why is this happening?
- python - Pandas Dataframe: assigning a new column based comparing each value of one column to all the values of another
- python - def subplot(plt, (Y, X), (sz_y, sz_x) = (10, 10)): throws invalid syntax in Python 3