Guest User

Firechat Messaging

a guest
Sep 22nd, 2016
110
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <link rel="stylesheet" href="https://cdn.firebase.com/libs/firechat/3.0.1/firechat.min.css" />
  2. <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
  3. <script src="https://cdn.firebase.com/libs/firechat/3.0.1/firechat.min.js"></script>
  4.  
  5. <div id="firechat-wrapper"></div>
  6.  
  7. <script type="text/javascript">
  8. var chatRef = firebase.database().ref();
  9. var chat = new FirechatUI(chatRef, document.getElementById("firechat-wrapper"));
  10. firebase.auth().onAuthStateChanged(function(user) {
  11. if (user) {
  12. chat.setUser(user.uid, "Anonymous" + user.uid.substr(10, 8));
  13. } else {
  14. firebase.auth().signInAnonymously().catch(function(error) {
  15. console.log("Error signing user in anonymously:", error);
  16. });
  17. }
  18. });
  19. </script>
RAW Paste Data