-
Notifications
You must be signed in to change notification settings - Fork 5
Chat App
In this lesson we will be creating a chat app that sends and receives messages in real time. We will be using Firebase as our database, and also incorporate voice recognition.
We will need a database to store all the messages. Firebase is a database that will allow us to store, and receive messages in real-time. Here are the Firebase code blocks that we will be using.
The VoiceRecognizer component allows us to use the built in Google Voice Recognition API (Application Programmer Interface) of the phone. Here are the VoiceRecognizer code blocks that we will be using.
We will be using the SystemTime block from the Clock component. This will allow us to get a somewhat unique and in order key for our key-value Firebase database.
We will need a text box, two buttons, a ListView, a Firebase component, a Clock component, and a VoiceRecognizer component.
- Create an event handler for the SendButton
- Use the Firebase StoreValue block to store the message from the MessageBox as the value. For the tag, use the SystemTime from the clock component.
- After the Firebase StoreValue, reset the MessageBox to " " so the user can enter the next message
- Initialize a list to store the messages to an empty list.
- Use the Firebase DataChanged block to add the message values to the variable you initialized in step 1. Note: be sure to add the new messages to the start of the list, not the end (hint: use index 1)
- Set the MessageList to the message variable. This will ensure that the GUI actually updates with the new messages.
You should be able to send and receive messages.
- See if you can figure this out yourself. The code is very similar to the SendButton. Be sure to use SpeechRecognizer GetText, and SpeechRecognizer AfterGettingText blocks.
- Make your app play a sound every time you send or receive a message.
- Make you app speak the new incoming messages.
- Instead of just showing the message, show the system time, then the message in the format TIME: MESSAGE