Chat with push notification (CloudDB and Itoo)

Since the release of the "Itoo 4.1 Sky" version, this extension can interact with the AppInventor component "CloudDB"

We are going to create a Chat application with Push notification relying on this great extension

There is already a manual on how to create a chat with CloudDB

https://appinventor.mit.edu/explore/ai2/clouddb-chat

In this tutorial we will focus on creating a service that allows us to add push notifications to Chat.

In Screen1.Initialize we indicate the following

First we will start the service

Then we will include our chat user in the shared variable "user"

When we start the service we call the "Start" procedure

There we find the itoo procedure "ExecuteInternalScript" with two arguments:

  • Code: which is a control number
  • Values: there we will include a list with six items, to configure CloudDb
    1- The CloudDB Component
    2- The ProjectId (by changing this data we could make different chat rooms)
    3-RedisPort
    4-RedisServer (clouddb.appinventor.mit.edu)
    5-Token (Redis server start key)
    6-UseSSL (true or false)

This data must match what is indicated in the component properties except RedisServer

In this same "Start" procedure we register the CloudDB1.DataChanged event in the "DataChanged" procedure

propiedades

DataChanged

The "value" argument, as defined in the program, is a list but for reasons unknown to me, the service identifies it as a string, but there are enough tools in App Inventor to extract the data we need.

What the procedure does is remove the user and the message from the last post and present it to us in a notification, this is done even if the app is closed

When you press the notification, the app will open and the chat will be updated in it.

This is a basic chat, but you can go deeper by creating rooms and users with permissions to enter a certain room, you could even create private one-on-one conversations, it all depends on the imagination we have.

Even with our Driver account, we could share all types of files.

For correct operation on Xiaomi and Samsung devices, it is convenient to set the battery saver to No Restrictions.

The notification would have to be configured for the NotifyBasic channel as Allow floating notifications.

ItooChat.aia (105,6 KB)

3 Likes

Hmm. I think this is related to how the CloudDB component operates rather than the Itoo extension.
Does this also happen without using a background process? Your findings will be useful.

Thanks,
Kumaraswamy B G

According to the manual on how to create a chat with CloudDb, the value argument of DataChanged can have a list as its value

https://appinventor.mit.edu/explore/ai2/clouddb-chat

Can you confirm that when you upload the data to CloudDB, it is in the form of a list or a string?

If you use "AppendValueToList", value will be a list. If you use StoreValue, it will depend on the value you are storing.

In chat example, it is used AppendValueToLis so, the returned value will be a list.

Yes, load the data as a list

2 Likes

A new version of the .aia file is included with the following improvements:

  • Now the service is activated when the device is turned off or restarted

image

  • Authentication is through our Google username, so users are kept unique.
    For this, the Taifun extension "TaifunGoogleAcount" is used (thanks to Taifun for the great extension)
  • Allows you to create different chat rooms
  • Allows you to send Private messages from User to User, the message is produced through a notification
  • If the body of the message is an https link, it will open what that link indicates (web page, pdf files, other types of reading files, photos, videos...)
  • Allows you to select whether we want to receive push notifications or not, private messages will always have a push notification.
  • For the chat design I used the ListViewPlus extension by Patryk_F. (thanks for your great extension)

I hope you like it and it helps you go deeper into the tutorial.

ItooChatV2.aia (310,7 KB)

3 Likes