ios - Firebase RTM multiple chat rooms with React Native -


i working on project create multiple chat rooms using react native , firebase.

when comes react native, firebase's documentation rather sparse , doesnt have many implementation examples.

i have chat works 1 on 1 chat, taken this example.

how add functionality add/remove private chat rooms add/remove users to? have tried using firechat api, unfortunately not work react-native.

here have far:

import firebase 'firebase';  class messagebackend {   uid=''   messagesref = null;   constructor(){     firebase.initializeapp({       apikey: '0000',       authdomain: '0000.firebaseapp.com',       databaseurl: 'https://0000.firebaseio.com/',       storagebucket: '0000.appspot.com',     });     firebase.auth().onauthstatechanged((user) => {       if (user) {         this.setuid(user.uid);       }else{         firebase.auth().signinanonymously().catch((error => {           alert(error.message);         }))       }     })    }    setuid(value){     this.uid = value;   }   getuid(){     return this.uid;   }   loadmessages(callback){     this.messagesref = firebase.database().ref('messages');     this.messagesref.off();     const onrecieve = (data) => {       const message = data.val();       callback({         _id: data.key,         text: message.text,         createdat: new date(message.createdat),         user: {           _id: message.user._id,           name: message.user.name         }       });     };     this.messagesref.limittolast(20).on('child_added', onrecieve)   }    sendmessage(message, uid){     var = new date().gettime()     (let i=0; < message.length; i++){       this.messagesref.push({         _id: now,         text: message[i].text,         user: message[i].user,         createdat: firebase.database.servervalue.timestamp,         uid: uid,       });     }   }   closechat() {     if (this.messagesref){       this.messagesref.off();     }   } }  export default new messagebackend(); 


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -