App Inventor Firebasedb Tutorial - Signup Login Screen
Hello friends and welcome to Obsidian Soft
Many friends had requested a tutorial for Firebase DB in MIT App Inventor so today I will teach you the easiest steps for setting up the Firebase database, connecting it to our MIT App Inventor app, and storing or getting data from it.
I will be using the example of my sign-up login app that I previously taught with CloudDB.
After watching this tutorial, you should be able to convert any app that uses cloudDB into a Firebase database app such as my chatting app, quiz app, customer record app, etc.
First, let’s make a simple user interface for our app.
Open up MIT App Inventor and start a new project. Give it an appropriate name.
For screen 1, make align horizontal and align vertical both center. Make the background color: blue.
Add a text box from the User Interface palette.
Rename it to nameTxt and make background-color: white. Make the width 50%, height 8%, font bold, and font size 20. Change the hint to “Enter user name”
Add a password textbook from the User Interface palette. Rename it to passTxt.
Give similar properties as nameTxt. Make the background color: white, font bold, font size 20. Make its width 50% and height 8%. Change the hint to “Enter password”
Add an empty label from the User Interface palette with height 1% between these two textboxes for spacing.
Add a horizontal arrangement from the Layout palette.
below the text boxes.
Make align horizontal and align vertical both center.
Make height 15% and width fill parent.
Drag and drop a button from the User Interface palette inside this horizontal arrangement. Rename it to loginBtn. Make the background color black. Make font bold, font size 22, width 35%, and change text to Login and color to white.
Select this button and duplicate by pressing Ctrl + C and Ctrl + V on the keyboard for Windows OR Command + C and Command + V on the keyboard for MacOS. Rename it to signupBtn and change the text to Signup.
Add an empty label with a width of 2% between these two buttons for spacing.
Add a Firebase component from the Experimental palette. Also, add a notifier component from the User Interface palette.
Now, we have to create and set up our Firebase realtime database.
Search for Firebasedb in Google and choose the first link. I will also give this link in the video description.
Make sure that you have logged in with your Google account.
Then click on “Go to console” button.
Click on Add Project.
Give it an appropriate name.
Accept the terms of service if they ask and click on the Create button.
Click on the Continue button on the Google Analytics screen.
Add a Google Analytics account and press the Create Project button. It will take some time.
The Project overview window will open.
Click on All products and in the dashboard, choose Realtime Database.
Click on the Create Database button.
Now, we have to set up our realtime database. First, choose the location.
Very important: Choose the United States option otherwise Firebase db component will give an error in your app (this was the case at the time of making this tutorial).
Click on the next button after choosing the location.
Let it stay in locked mode and click on the Enable button. The database will be created.
Once it has been created, go to rules.
Make read and write true.
Publish these changes.
This is a free plan called Spark and you are allowed 100 connections at a time and 1 GB data storage.
If you want more storage and connections, then upgrade from this plan.
Now go to the data tab and click on that pin-like icon to copy the URL.
Go back to your project in MIT App Inventor. Uncheck the "Use default" checkbox in firebaseDB component’s properties and paste the copied URL in the firebaseURL field.
Add another screen with just a label saying welcome
Now go to the blocks section. The code is the same as the one for the CloudDB app.
When the signup button is clicked, we will store the password as a value against the user name as a tag in the firebaseDB.
When the login button is clicked, we will get the password against the user name.
The getValue procedure will trigger the GotValue event. Here, we will check if the entered password is the same as the password retrieved as the value against the tag user name from the database. If it is the same, we will let the user log in and take him to the second screen. If not, we will show a message using the notifier.
So, this is done and you can see how easy it was to setup Firebase database and connect it to an MIT App inventor app.
I hope you liked this tutorial. Happy Coding!
If you like my tutorials, consider supporting me by buying me a cup of coffee by pressing the button below:
Please like my videos and share them with your friends and family. Also, subscribe to my channel and press the bell icon so you don't miss any of the great projects I have planned for you.
thanks a lot bro!
ReplyDeleteMost welcome :)
Delete