Go to firebase console and copy pasta the code they give you to setup connection.
Using Database/Firestore
Firestore allows you to live update data on as many devices as you want on the frontend. Add listeners to data.
For testing go to db setting, rules, and set read and write to true(allowing all users to read and write no auth)
Then you can add data
the DbRef gets the key value pair from text and on change changes the val of snap
var bigOne =document.getElementById('bigOne');var dbRef =firebase.database().ref().child('text');dbRef.on('value', snap =>bigOne.innerText =snap.val());
Firebase Authenication
Allows ease console setup of Facebook auth, twitter, github, etc where all the user objects look the same
constauth=firebase.auth();auth.signInWithEmailAndPassoword(email, pass);//return a promise where you can resolve that userauth.createUserWithEmailAndPassword(email, pass);//another promiseauth.onAuthStateChanged(firebaseUser => { });//fires callback on changes, firebaseUser = null when logout
Using the promise
Signup event
Ref Objects
In the cloud, event.data.ref
.child('specificChild')
.set(value) //returns promise
Delta Snapshot
.ref //to get about ref
.changed() //boolean if changed
.val() //to get the actual value there
Getting val
Adding Backend APIS / Cloud Functions
Could do clientside, but like secrets on client?? and write for every platform?? Require the APIS apparently @google-cloud/speech can be require(nodejs right). Then you add listener to upload file and then use api then write to translationed file. So you handle the conversion clientside. Then deploy these
Setup
Need firebase CLI npm install -g firebase-toolsfirebase login
function signUp(email, pass)) {
const promise = auth.createUserWithEmailAndPassword(email, pass);
promise.catch(e => console.log(e.message));
//catch errors but dont do anything on state change just make request
//using promise then would not allow auth changes
}
//SIGNOUT
firebase.auth().signOut();
//handle the auth state changes here
firebase.auth().onAuthStateChanged(firebaseUser => {
if(firebaseUser) {
//logged in
} else {
//not logged in
}
})