FirebaseExtended / firechat

Real-time Chat powered by Firebase
https://firechat.firebaseapp.com
MIT License
2.41k stars 1.04k forks source link

How to connect to firebase? #115

Open bsde1234 opened 4 years ago

bsde1234 commented 4 years ago
<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.

gerardorn commented 3 years ago

Here's the documentation

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