firechat icon indicating copy to clipboard operation
firechat copied to clipboard

How to connect to firebase?

Open bsde1234 opened this issue 6 years ago • 1 comments

<script>
  function login() {
    // Log the user in via Twitter
    var provider = new firebase.auth.TwitterAuthProvider();
    firebase.auth().signInWithPopup(provider).catch(function(error) {
      console.log("Error authenticating user:", error);
    });
  }

  firebase.auth().onAuthStateChanged(function(user) {
    // Once authenticated, instantiate Firechat with the logged in user
    if (user) {
      initChat(user);
    }
  });
</script>
<div class="top-pad"></div>
<button onclick="login()">Login with Twitter</button>
</div>
<script>
  function initChat(user) {
    // Get a Firebase Database ref
    var chatRef = firebase.database().ref("chat");

    // Create a Firechat instance
    var chat = new FirechatUI(chatRef, document.getElementById("firechat-wrapper"));

    // Set the Firechat user
    chat.setUser(user.uid, user.displayName);
  }
</script>

<div id="firechat-wrapper"></div>

I did only this. This code added to my html page. But how to connect to my firebase project. Is there any documentation.

bsde1234 avatar Dec 10 '19 03:12 bsde1234

Here's the documentation

https://firebase.google.com/docs/auth/web/firebaseui

gerardorn avatar Apr 20 '21 17:04 gerardorn