function addGlobalMessageToDB(message) {
    var userNotificationArr = [];
    for (var i = 0; i < userArr.length; i++){
      if(userArr[i].notifications == undefined){
        userNotificationArr = [];
      } else {
        userNotificationArr = userArr[i].notifications;
      }
      userNotificationArr.push(message);

      if(userArr[i].notifications == undefined) {
        firebase.database().ref("users/" + userArr[i].uid).update({notifications:{0:message}});
      } else {
        firebase.database().ref("users/" + userArr[i].uid).update({
          notifications: userNotificationArr
        });
      }
    }
  }
//This function adds the private message to all users onto the database
This function adds the private message to all users onto the database
This function adds the private message to all users onto the database
function addGlobalMessageToDB(message) {
    var userNotificationArr = [];
    for (var i = 0; i < userArr.length; i++){
      if(userArr[i].notifications == undefined){
        userNotificationArr = [];
      } else {
        userNotificationArr = userArr[i].notifications;
      }
      userNotificationArr.push(message);
      if(userArr[i].notifications == undefined) {
        firebase.database().ref("users/" + userArr[i].uid).update({notifications:{0:message}});
      } else {
        firebase.database().ref("users/" + userArr[i].uid).update({
          notifications: userNotificationArr
        });
      }
    }
  }
function addGlobalMessageToDB ( message ) { var userNotificationArr = [ ] ; for ( var i = 0 ; i < userArr . length ; i ++ ) { if ( userArr [ i ] . notifications == undefined ) { userNotificationArr = [ ] ; } else { userNotificationArr = userArr [ i ] . notifications ; } userNotificationArr . push ( message ) ; if ( userArr [ i ] . notifications == undefined ) { firebase . database ( ) . ref ( "users/" + userArr [ i ] . uid ) . update ( { notifications : { 0 : message } } ) ; } else { firebase . database ( ) . ref ( "users/" + userArr [ i ] . uid ) . update ( { notifications : userNotificationArr } ) ; } } }
This function adds the private message to all users onto the database
This function adds the private message to all users onto the database