Friday 10 April 2020

Liked on YouTube: How to build your own chat app in MIT app inventor 2

How to build your own chat app in MIT app inventor 2

In this video, we will create Online Forum app in MIT app inventor 2, This app is a simple app that uses the CloudDB component to store data in the cloud and allows multiple users of the app to communicate over multiple devices. Download Code-: https://ift.tt/3e53vQW Go to ai2.appinventor.mit.edu and start a new project. Initialize one variables, as follows: chatList: stores all chat messages in a list Drag out a SubmitButton.Click event block, You will be saving those messages to CloudDB, the "Cloud Database". You will append the new message to the chat list already stored in CloudDB. For a tag, simply use "chat", and join the userName, a colon, and the message so it will appear that way when displayed. And finally, for either situation, clear the TextBox. When the app first starts, you need to check if there are already chat message other users may have sent, and you need to display them. Add a Screen1.Initialize block, and in it, call CloudDB1.GetValue to get any existing chat messages from CloudDB. If no value is found, return an empty list, since your chat messages are kept in a list. When you call CloudDB1.GetValue, it asks CloudDB for that tag’s current value. So there is a callback event, CloudDB1.GotValue, that is triggered when CloudDB responds to GetValue. First check whether the tag is the correct one ("chat") using an if-then block. If so, then save the value, which should be the list of messages, into the global variable chatList.. Then set ListView1.Elements to the list of messages, so they will be displayed in the ListView. The CloudDB1.DataChanged event is triggered whenever anyone using the app updates CloudDB, so this event is triggered whenever any new message by anyone is sent. This block should essentially do the same thing as the GotValue block, so you can right-click and Duplicate then inner blocks from GotValue, and snap them into DataChanged. That is it! Now it's time to test! The best way to test an app using CloudDB and multiple users, is to use multiple devices. The MIT AI2 Companion does not always allow for mutiple users to connect at the same time, so the better option is to build the apk, and install your app on more than one mobile device. From the Build menu, choose "App (provide QR code for .apk)". Once the apk is built, scan the generated QR code, and install the apk on multiple devices. Then send a message from each device. All messages should appear on all devices. You can also close the app, and restart it, and you should see the history of messages. How cool is that? Expand your App Here are some ideas to enhance your Chat app! Reverse the order of the chat messages displayed so that the latest message is always displayed at the top. Hint: use reverse list block Indicate when a person has joined the chat such as “Selim has joined the Chat” in case they decide not to send any messages for a while. Add a timestamp to each message. Add a Clear button to clear out previous messages. Add chat rooms, where users must specify a room they want to join. thunkable
via YouTube https://www.youtube.com/watch?v=IXohhtilECk

No comments:

Post a Comment

😍Developer on Weekends #shorts #officememes #developermemes

😍Developer on Weekends #shorts #officememes #developermemes Welcome to the latest viral YouTube shorts meme for developers! 😍Developer on...