react-native-background-job icon indicating copy to clipboard operation
react-native-background-job copied to clipboard

BackgroundJob tried to override BackGroundJobModule

Open gj1118 opened this issue 6 years ago • 1 comments

Hi, I am getting this message

image

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

gj1118 avatar Apr 02 '18 17:04 gj1118

It looks like you tried to require the module twice. Can you check your Java files?

vikeri avatar Apr 03 '18 08:04 vikeri