Sunday, October 14, 2018

What is Google Firebase? Create a Firebase chat application

Firebase is a mobile platform that helps you quickly develop high-quality applications, develop applications for large-scale users, and earn more.

Firebase Analytics

Is a free solution and analysis is not limited. Manage user behavior and measures from a single dashboard.

Firebase Develop

Build better apps and do better. Important in saving time developing high quality, application has few bugs.
  • Cloud Messaging  is a free, multi-platform messaging solution. Each message counts up to 4KB in a client application.
  • Firebase Authentication  Most applications require authentication. Helps the application save secure data used in the cloud.
  • Firebase Realtime Database  NoSQL Cloud Database Synchronization. Data is synchronized across all clients in real time, and is always available when the application is offline.
  • Firebase Storage  is built for application developers, for storing and serving user-created content, such as images or video.
  • Firebase Hosting is  fast and secure static hosting for web applications.
  • The Firebase Test Lab  provides virtual and physical devices that allow running simulation simulations of actual use environments
  • Firebase Crash Reporting  Comprehensive information and actions to help diagnose and repair problems in the application.

Firebase Grow

  • Notifications  allows the user to send and maintain messages. Usage is free and unlimited.
  • Remote Config  Updates the app without deploying a new version. Easy installation.
  • App Indexing  Helps users discover and re-engage with your app by displaying relevant in-app content in Google search results.
  • Dynamic Links  are smart URLs that automatically change the behavior to provide the best on different platforms. Dynamic linking may exist in the application's installation process and send users to relevant content whether they are a new user or a longtime customer.
  • Invites  application introduction and sharing.
  • AdWords  Automatically associates AdWords with users you specify in Firebase Analytics. Improve your ad targeting and optimize your campaign performance.

Deploy the Firebase web chat application

1. Overview
You will learn how to use Firebase-based platforms to easily create web applications and you will implement and deploy a Firebase-based chat application.
You will learn
  • Firebase Realtime Database and Firebase Storage Synchronization.
  • Authenticate users using the Firebase Auth base.
  • Deploy your web applications into static storage
You will need what to do
  • Editing content using WebStorm, Atom, Sublime, Notepad ++
  • Sample code
  • Use the Chrome browser
2. Download the sample code
The sample code above is github download here:  https://github.com/firebase/friendlychat
firebase-codelabs sample project container for multiple platforms. This codelab uses only directories:
  • web-start  is the sample code you will follow the following instructions
  • Visit  The complete code for the sample application works
3. Create a Firebase project and install your application
Chọn Add Firebase to your web app
Copy the html code and the index.html file   of the sample code above
Activate Google user authentication
4. Install the web server local to run the modified sample code
5. Start the application
Go to http://127.0.0.1:8887/ to see the interface of the web application as follows
6. Register account login
Modify the FriendlyChat.prototype.initFirebase function   in the script / main.js file   so that it configures the Firebase SDK and initializes the auth:
Authenticate user access to Google
Change the function  FriendlyChat.prototype.signIn  function:
Change the function  FriendlyChat.prototype.signOut  function:
You want to display the profile image of the login user and the name on the menu bar. You must set the FriendlyChat.prototype.onAuthStateChanged function   to enable when changing the auth state. This function is passed to an object using firepower when activated. Change two lines with a TODO:
You want to display an error message if the user tries to send the message when the user is not logged on. To detect if the user is actually logged in add the first few lines of the FriendlyChat.prototype.checkSignedInWithMessage function   where TODO:
Verify that the login is working
  • Reload this link http://127.0.0.1:8887/
  • Click the Sign in button
  • After completing the login, you will only see the image of the user
Note: In addition to authenticating user rights, Firebase also validates the URL that is allowed to run the application. By default, the URLs allowed are: localhost and * .firebaseapp.com. To add more URLs, follow the image below

7. Send and read messages
To synchronize messages in the app, you will need to add trigger events when changes are made to the data and then create a UI element that shows the new message.
Adding that code triggers new messages added to the application's user interface. To do this modify the  FriendlyChat.prototype.loadMessages  function. This is where the subscriber will subscribe to the listener for change on the data. They will only display the 12 latest chat messages to avoid displaying a very long history.
To send user messages to the Firebase database, we change the  FriendlyChat.prototype.saveMessage
Check sync messages
Check on user browser
Check out the google firebase admin page
So it's a very simple web-based chat application that just needs a bit of html editing and a google firebase subscription. With the creation of firebase chat applications using HTML and Javascript, you can deploy to the following systems: Asp.net, PHP, Java ... are both.

No comments:

Post a Comment