我一直在尝试集成晶体管软件后台抓取库,但没有成功: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原生链接,并将其安装在package.json中
...
{
...
"react-native-background-fetch": "^2.5.3",
...
}
...发布于 2019-05-03 22:42:17
该问题是由于未正确配置Expokit以使用本机模块造成的。我制作了一个简单的React Native应用程序,这个库可以正常工作而不会返回错误。
https://stackoverflow.com/questions/55838106
复制相似问题