No doubt, MIT app inventor is one of the easiest ways to develop apps for project or hobby. If you want to develop a simple IOT based project, you certainly need a real-time database. Though there are many players in the game but google firebase is best among all. So here is a tutorial on How to use firebase with MIT app inventor or How to integrate firebase with MIT app inventor 2.
What Is Google Firebase And What Is Google Firebase Used For?
Firebase is primarily used for app development, cloud messaging, real-time database, storage, hosting, social authorization, and analytics.
Firebase is a platform offered by Google which can be used as backend storage. In simple words, we can say that firebase is a cloud-based database. It provides one of the most stable and fastest real-time databases.
Here, in this post, we are going to use Google firebase as a real-time database. First of all, we will see how to integrate firebase with MIT app inventor 2. After that, we will get deep into how to use the app inventor to read data from firebase. We will also see, MIT app inventor logic to update the database using an app.
How to use firebase with MIT app inventor 2.
Integrating firebase with app inventor is straightforward and it can be done in 3 simple steps.
1. Create real-time database
- Navigate to Google Firebase and login using your google account. It will redirect you to Google firebase console.
- Click on new project, enter a project name and cloud firestore location, then hit create project button.
- Search for Develop option in the left panel, then expand Develop and select Database. It will open the firebase database catalog. Scroll down to select real-time database and click on create database button.
- Keep Security rules for Real-time Database in locked mode and enable it.
Now your database is enabled and online. Its time to find out secret database details (URL + KEY) so that you can access it remotely.
2. Find real-time database authorization details
Open your database and copy Real-time database URL. Paste the link to firebase database on the notepad.
Click on Project Overview option on the left panel and select project settings. Navigate to Service accounts >> Database secrets >> Secret. Copy the database authentication key and save in a safe location.
3. Integrate firebase with MIT app inventor
- First of all, go to MIT app inventor home page, click on create apps and login using valid credentials.
- Find the “Experimental” option (located in the left palette window) and expand it. Drag and drop “FirebaseDB” in the workspace (viewer window).
- After that, create a new project and give it any desired name.
- Left click on FirebaseDB1 (at bottom of viewer window) to see properties of the database. In the properties window, paste database URL and database secret key (copied in step 2).
- That’ it, now you are ready to use google firebase with MIT app inventor. Now, let’s dig a little bit deeper in how to read/write data from/to firebase using app inventor.
How To Write Data To Firebase Using MIT App Inventor?
As we say, the best way to learn something is to do it (Do it Lean it), let’s create a simple app which can write data to firebase. At this point, I am assuming that you had already integrated firebase with app inventor. Now we need to add some other components.
- Drag and drop a TextBox and a Button to the workspace. Click on the button and give it a name (let it be “Write Data”).
- After that, click on BLOCKS option located at the top right corner of Windows. This is workspace where we will write our logic. Create logic as shown below.
- Then click on build and save apk file to your PC, transfer file to smartphone and install on it.
Run the app, enter something in the text field and click the button. Your data would be saved to firebase. You can view saved data by visiting Google firebase console.
How To Read Data From Firebase Using MIT App Inventor?
- Drag a label and second button (let it be Read Data).
- Add code blocks as shown below. Save it and run on any android device or android emulator.
After that, go to console and edit value manually or write any value using app. Then press “read data” button and it will fetch and show new data in label.
In this way you can update or fetch data from firebase. You can use it for developing app or any IOT based project. So what are you waiting for? Go and expand your wings of creativity!
Still have any doubt? Check out this awesome video by Tech Mania. And Tech Mania, if you are reading this, A BIG THANKS for making the helpful video 😉
For further reading, you can also check out a demonstration for app using firebase.
Wrapping UP!
Hope you find this tutorial useful. Please feel free for queries. And Best Of Luck for upcoming IOT adventures.
Richy….THANK YOU very much for this post or blog.
ALL information on Youtube, Google, shown a parts with Firebase with RULES on “TRUE”, Read an Write, BUT the REAL WORK is with these two rules protected, and the Database Protected.
All tests and hours of reading and see videos with the simple solution of unblock the database is for create the app only, but not to work.
You explain very well this BIT or BIG information to continues the app.
Thank you newly
Hi Mauricio,
Thanks for leaving your valuable feedback.
Cheers
did you found how to set up rules for REAL ENVIROMENT.. thanks !
i want to read my data only is that possible ? and you are steps are not working for me?
Hi Santhosh,
Yes, its possible to read data.
What error you are getting? Are you sure that secret key is correct?
Hi, I got a question, when we read data form Firebase Databased, is it stored in phone? Or as soon as we close it i gets deleted, or it is never downloaded?
Hi Kevin,
Data is stored temporarily in app. It gets deleted after closing app.
Thanks
Great tutorial! thanks for sharing mate!
You’re Welcome 🙂
sir what is fire base token where we can got please help sir
Hi there,
Firebase token is like password (secret key) which can be used to access firebase real time database.
To get it, please navigate to Firebase control panel >> Project overview >> Project settings >> service accounts >> Database secrets >> Secret, then copy it.
Hi can I ask can it only store 1 piece of data at once or can it store many pieces of data?
Hi
It can store many piece of data in different keys.
But only one value per key.
Thanks
Olá
Tenho uma aplicativo que precisa ler 3 tags diferentes no firebasedb, como fazer a leitura de 3 lables diferentes?