我一直在尝试集成晶体管软后台获取库,但没有成功: 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",
...
}
...
答案 0 :(得分:0)
该问题是由于未正确配置Expokit来使用本机模块而引起的。我制作了一个简单的React Native应用程序,该库正常运行而没有返回错误。