error while fetching notification data from firebase












0















Hello I'm new in react native. I'm working on push notifications through firebase. I have implemented the functionality of notification. But the problem is I'm not able to fetch the data from the firebase real time database. Here is my code to fetch the data from firebase. I just want to fetch the events which is shown in image.



fetchFriendsList=(eventId)=>{
let allEventsList = [...this.state.allEventsList];

firebase.database().ref('/events').child(eventId).once('value').then((snapshot) => {
let data = snapshot.val();
let items = Object.values(data);

allEventsList.push(items);
this.setState({allEventsList : allEventsList});
ToastAndroid.show("kk>"+allEventsList.length , ToastAndroid.SHORT);
}).then((data)=>{

}).catch((error)=>{
//error callback
console.log('error ' , error)
})
}

//get event id from user events
deleteOldEvents=()=>{
let eventsList = [...this.state.userEventsList];

for(var i=0;i<eventsList.length;i++){
this.deleteFromFireBase(eventsList[i].eventId)
}
}

//app users remove that not in contacts
deleteFromFireBase=(eventId)=>{
let timeRemaining = 1;
firebase.database().ref('/events').child(eventId).once('value').then((snapshot) => {
let data = snapshot.val();
let STime = data.sTime; // start time
let eventDate = data.eventDate;
timeRemaining=this.remainingTimeInMin(STime,eventDate);
}).then((data)=>{
//remove from events
if(timeRemaining < 0){
this.setState({removeEventsList:});

firebase.database().ref('/events').child(eventId).child('friends').once('value').then((snapshot) => {
let data = snapshot.val();
let items = Object.values(data);
this.setState({removeEventsList:items});
}).then((data)=>{
//remove event data from users node
let removeEventsList = [...this.state.removeEventsList];

for(var i=0;i<removeEventsList.length;i++){
let getPhone= removeEventsList[i].phone
firebase.database().ref('/users').child(getPhone).child('/events').child(eventId).remove();
}

//remove whole event from event node
firebase.database().ref('/events').child(eventId).remove();
}).catch((error)=>{
//error callback
console.log('error ' , error)
})
}
}).catch((error)=>{
//error callback
console.log('error ' , error)
})
}


enter image description here










share|improve this question





























    0















    Hello I'm new in react native. I'm working on push notifications through firebase. I have implemented the functionality of notification. But the problem is I'm not able to fetch the data from the firebase real time database. Here is my code to fetch the data from firebase. I just want to fetch the events which is shown in image.



    fetchFriendsList=(eventId)=>{
    let allEventsList = [...this.state.allEventsList];

    firebase.database().ref('/events').child(eventId).once('value').then((snapshot) => {
    let data = snapshot.val();
    let items = Object.values(data);

    allEventsList.push(items);
    this.setState({allEventsList : allEventsList});
    ToastAndroid.show("kk>"+allEventsList.length , ToastAndroid.SHORT);
    }).then((data)=>{

    }).catch((error)=>{
    //error callback
    console.log('error ' , error)
    })
    }

    //get event id from user events
    deleteOldEvents=()=>{
    let eventsList = [...this.state.userEventsList];

    for(var i=0;i<eventsList.length;i++){
    this.deleteFromFireBase(eventsList[i].eventId)
    }
    }

    //app users remove that not in contacts
    deleteFromFireBase=(eventId)=>{
    let timeRemaining = 1;
    firebase.database().ref('/events').child(eventId).once('value').then((snapshot) => {
    let data = snapshot.val();
    let STime = data.sTime; // start time
    let eventDate = data.eventDate;
    timeRemaining=this.remainingTimeInMin(STime,eventDate);
    }).then((data)=>{
    //remove from events
    if(timeRemaining < 0){
    this.setState({removeEventsList:});

    firebase.database().ref('/events').child(eventId).child('friends').once('value').then((snapshot) => {
    let data = snapshot.val();
    let items = Object.values(data);
    this.setState({removeEventsList:items});
    }).then((data)=>{
    //remove event data from users node
    let removeEventsList = [...this.state.removeEventsList];

    for(var i=0;i<removeEventsList.length;i++){
    let getPhone= removeEventsList[i].phone
    firebase.database().ref('/users').child(getPhone).child('/events').child(eventId).remove();
    }

    //remove whole event from event node
    firebase.database().ref('/events').child(eventId).remove();
    }).catch((error)=>{
    //error callback
    console.log('error ' , error)
    })
    }
    }).catch((error)=>{
    //error callback
    console.log('error ' , error)
    })
    }


    enter image description here










    share|improve this question



























      0












      0








      0








      Hello I'm new in react native. I'm working on push notifications through firebase. I have implemented the functionality of notification. But the problem is I'm not able to fetch the data from the firebase real time database. Here is my code to fetch the data from firebase. I just want to fetch the events which is shown in image.



      fetchFriendsList=(eventId)=>{
      let allEventsList = [...this.state.allEventsList];

      firebase.database().ref('/events').child(eventId).once('value').then((snapshot) => {
      let data = snapshot.val();
      let items = Object.values(data);

      allEventsList.push(items);
      this.setState({allEventsList : allEventsList});
      ToastAndroid.show("kk>"+allEventsList.length , ToastAndroid.SHORT);
      }).then((data)=>{

      }).catch((error)=>{
      //error callback
      console.log('error ' , error)
      })
      }

      //get event id from user events
      deleteOldEvents=()=>{
      let eventsList = [...this.state.userEventsList];

      for(var i=0;i<eventsList.length;i++){
      this.deleteFromFireBase(eventsList[i].eventId)
      }
      }

      //app users remove that not in contacts
      deleteFromFireBase=(eventId)=>{
      let timeRemaining = 1;
      firebase.database().ref('/events').child(eventId).once('value').then((snapshot) => {
      let data = snapshot.val();
      let STime = data.sTime; // start time
      let eventDate = data.eventDate;
      timeRemaining=this.remainingTimeInMin(STime,eventDate);
      }).then((data)=>{
      //remove from events
      if(timeRemaining < 0){
      this.setState({removeEventsList:});

      firebase.database().ref('/events').child(eventId).child('friends').once('value').then((snapshot) => {
      let data = snapshot.val();
      let items = Object.values(data);
      this.setState({removeEventsList:items});
      }).then((data)=>{
      //remove event data from users node
      let removeEventsList = [...this.state.removeEventsList];

      for(var i=0;i<removeEventsList.length;i++){
      let getPhone= removeEventsList[i].phone
      firebase.database().ref('/users').child(getPhone).child('/events').child(eventId).remove();
      }

      //remove whole event from event node
      firebase.database().ref('/events').child(eventId).remove();
      }).catch((error)=>{
      //error callback
      console.log('error ' , error)
      })
      }
      }).catch((error)=>{
      //error callback
      console.log('error ' , error)
      })
      }


      enter image description here










      share|improve this question
















      Hello I'm new in react native. I'm working on push notifications through firebase. I have implemented the functionality of notification. But the problem is I'm not able to fetch the data from the firebase real time database. Here is my code to fetch the data from firebase. I just want to fetch the events which is shown in image.



      fetchFriendsList=(eventId)=>{
      let allEventsList = [...this.state.allEventsList];

      firebase.database().ref('/events').child(eventId).once('value').then((snapshot) => {
      let data = snapshot.val();
      let items = Object.values(data);

      allEventsList.push(items);
      this.setState({allEventsList : allEventsList});
      ToastAndroid.show("kk>"+allEventsList.length , ToastAndroid.SHORT);
      }).then((data)=>{

      }).catch((error)=>{
      //error callback
      console.log('error ' , error)
      })
      }

      //get event id from user events
      deleteOldEvents=()=>{
      let eventsList = [...this.state.userEventsList];

      for(var i=0;i<eventsList.length;i++){
      this.deleteFromFireBase(eventsList[i].eventId)
      }
      }

      //app users remove that not in contacts
      deleteFromFireBase=(eventId)=>{
      let timeRemaining = 1;
      firebase.database().ref('/events').child(eventId).once('value').then((snapshot) => {
      let data = snapshot.val();
      let STime = data.sTime; // start time
      let eventDate = data.eventDate;
      timeRemaining=this.remainingTimeInMin(STime,eventDate);
      }).then((data)=>{
      //remove from events
      if(timeRemaining < 0){
      this.setState({removeEventsList:});

      firebase.database().ref('/events').child(eventId).child('friends').once('value').then((snapshot) => {
      let data = snapshot.val();
      let items = Object.values(data);
      this.setState({removeEventsList:items});
      }).then((data)=>{
      //remove event data from users node
      let removeEventsList = [...this.state.removeEventsList];

      for(var i=0;i<removeEventsList.length;i++){
      let getPhone= removeEventsList[i].phone
      firebase.database().ref('/users').child(getPhone).child('/events').child(eventId).remove();
      }

      //remove whole event from event node
      firebase.database().ref('/events').child(eventId).remove();
      }).catch((error)=>{
      //error callback
      console.log('error ' , error)
      })
      }
      }).catch((error)=>{
      //error callback
      console.log('error ' , error)
      })
      }


      enter image description here







      reactjs firebase react-native npm push-notification






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 20 '18 at 10:12









      sketchthat

      1,9431918




      1,9431918










      asked Nov 20 '18 at 9:39









      shabnam singhshabnam singh

      568




      568
























          0






          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53390076%2ferror-while-fetching-notification-data-from-firebase%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53390076%2ferror-while-fetching-notification-data-from-firebase%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          How to change which sound is reproduced for terminal bell?

          Can I use Tabulator js library in my java Spring + Thymeleaf project?

          Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents