react-native-background-job
react-native-background-job copied to clipboard
BackgroundJob tried to override BackGroundJobModule
Hi, I am getting this message
after do I do an install and then link it. Here is the code that I am using.
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import { PermissionsAndroid } from "react-native";
import Toast from 'react-native-simple-toast';
import SmsListener from 'react-native-android-sms-listener';
import BackgroundJob from 'react-native-background-job';
export default class App extends React.Component {
constructor(props) {
super(props);
this.state = {messages : {}, count: 0, lastMessage: ""}
}
componentDidMount() {
console.log("Gagan says that the => Component is mounted")
this.getAll();
BackgroundJob.schedule({
period: 100,
timeout: 1000
});
}
componentWillUnMount () {
console.log("Component will be unmounted")
// this.SMSReadSubscription.remove();
}
getAll() {
BackgroundJob.getAll({
callback: () => {
SmsListener.addListener(message => {
if(message && message.body) {
Toast.showWithGravity(message.body, Toast.LONG, Toast.TOP)
} else {
Toast.showWithGravity("Nothing was received", Toast.LONG, Toast.TOP)
}
this.setState({ lastMessage: message.body });
});
}
});
}
render() {
return (
<View style={styles.container}>
<Text>Open up App.js to start working on your app!</Text>
<Text className="imp">{this.state.count}</Text>
<Text className="imp">{typeof(this.state.messages)}</Text>
<Text className="imp">{this.state.lastMessage}</Text>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
imp : {
color:'#e74c3c'
},
});
Can you please let me know what is the issue here, please . ?
Thanks and Regards Gagan
It looks like you tried to require the module twice. Can you check your Java files?