FirebaseDB

FirebaseDB is the new App Inventor web database. Kind of. The uncertainty stems from the fact that this new web database component is currently being beta tested and will be updated based on user feedback. You can try it out, but don’t get too attached to its current form, because features may change by the time it is fully integrated. In case you forget this fact, you will be reminded every time you try to add this component to your project. Housed under the “Experimental” Palette drawer in the Designer, dragging this non-visible component to the Viewer will result in an alert reminding you of its provisional existence.

Fire 1Fire 2

I already love FirebaseDB and use it as if its current form were a permanent addition to my coding repertoire. Why is FirebaseDB so great?

Databases are used for many of reasons in mobile apps such as: to keep track of high scores in a game, to count the number of votes in an election, to save a variety outgoing text messages or to store the names of RSVPs to a book club event. FirebaseDB stores data in the cloud, which is helpful if you are perhaps vying to become a high scorer of a game. For such apps, both the app programmer and app user want this sort of data to be shared and persistent, meaning that once the app closes, the information is not gone forever, it will be saved and retrieved for all to see once the app reopens.

Fire 3.png

Example: For a simple note-taking app, users enter their username and a note and the app will display the note, the username and a time/date stamp. For this app to work, it must save and display notes from different users on various devices- a perfect scenario for FirebaseDB.

We programed this app so that when the user clicks “Submit,” the app stores data using the StoreValue block. In this case, it adds the values (user’s name, note, and date/time stamp) to a list called “global notes”. This information gets stored in the FirebaseDB under the tag that we named, “notelist”.

Fire 4.png

Each time the app opens, the GetValue block requests the most updated values stored under the “notelist” tag from the Firebase Service. When the value is received, the GotValue event fires retrieving the values saved in “notelist” and displays them in a List View.

The Firebase DataChanged event gets triggered anytime any user adds a new note. This is the amazing part because with FirebaseDB, all app instances receive this data and thus, are consistent. The previous App Inventor web database, TinyWebDB, did not have the ability to share data globally in this manner.

Fire 5.png

To become familiar with FirebaseDB, try building this note taker app and test how values from various users get saved, updated and displayed Or better yet, build a game app and see people around the world vie for the top scorer position!

 

 

 

*Note that the App Inventor emulator does not support the FirebaseDB component.

 

 

Advertisements

One Response

  1. […] to program with FirebaseDB with these app modules: NoteTaker and […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: