BUILDING REALTIME MOBILE APPS WITH FIREBASE
Moyinoluwa ADEYEMINovember 28, 2015
Firebase is a powerful platform for building realtime feature-rich apps
Realtime Database
NoSQL JSON data store
Cross-platform client-side SDKs
Restful API
Works Offline
Auto-scaling
Authentication
Anonymous
Email / password
Social
Custom
Hosting
Free static asset hosting
SSL certificate
Global CDN
Single command deploys
One-click rollbacks
Custom domains
So you want to learn how to build a realtime mobile chat application with Firebase?
Sign up on https://www.firebase.com/ to get a firebase (data) url
Add the library dependency directly to your app’s gradle.build file
In cases of build errors caused by duplicate files, exclude those files by adding these too
Connect your app to Firebase
Edit your AndroidManifest.xml file
First, request an INTERNET permission in the <manifest> tag
Next, change the name of the application
Create a Chat Model class
Send a message to FirebaseCreate a new Activity, complete with a layout that looks better than this. Be sure to add a <ListView />, an <EditText /> for collecting messages and a <Button /> for sending the data.
Send a message to Firebase
Create a reference to Firebase in the Activity and insert your own firebase url.
Send a message to Firebase
Retrieve the text from the EditText and push to Firebase
Retrieve a message from Firebase
Create a layout for the chat. It could look like this, or even better
Retrieve a message from Firebase
Create a ChatAdapter class that extends FirebaseListAdapter
Retrieve a message from Firebase
Create a ChatAdapter class that extends FirebaseListAdapter
Retrieve a message from Firebase
Override onStart() in MainActivity to read and display the messages
Retrieve a message from Firebase
Override onStop() in MainActivity to remove all the data
Implement offline functionality with Firebase
With just one line of code… seriously
Woohoo!!!
You now have a very basic Firebase app that sends, receives, displays messages and functions offline.
Credits
The official Firebase Chat App example was modified to produce this app.
The complete app including Login functionality implemented with Firebase is available on Github here:
https://github.com/moyheen/LagosFirebaseCodelab
Twitter LinkedIn GithubMoyinoluwa ADEYEMI
Thank You!
Top Related