Message notification

So I have a message system in my app but I need that the user can receive a notification on the home page if they have a new message , how could I do that ?

1 Like

Did you setup a Type called messaging in the database?

1 Like

On your ā€œmessageā€ data type, you will need a ā€œread?ā€ yes.no indicator.

Then you can sum up the ā€œunreadā€ messages for the user, and create a notification or put the count on the badge.

When the user reads their messages you can update the indicator to ā€œyā€.

4 Likes

Thanks but can you be more detailed in how to do this ?

1 Like

Hi,

Create a data type called ā€˜Notificationā€™ then set the following fields:

ā€˜Recipientā€™ of type ā€˜Userā€™
ā€˜Readā€™ of type ā€˜Yes/noā€™
ā€˜Messageā€™ of type ā€˜Textā€™

Then when you create a message youā€™ll also create a notification to the recipient user by creating a new ā€˜Notificationā€™, setting the ā€˜Recipientā€™ to the user receiving this message, and then ā€˜Readā€™ to No and Message to the notification message.

Then in a popup or on a notification page youā€™ll want a repeating group that does a search for notifications with a constraint where the recipient = current user

Job done :slight_smile:

1 Like

Correct. But personally I would choose to do it the way Nigel explained because youā€™re probably never going run useful queries on a Notification Type. So, adding a Boolean True or False on the existing type ā€œMessageā€ is simpler and wonā€™t clog your database if your application gets very popular.

*I always think long term when I create an application because databases could easily add hours of work if not weeks to your project if not set up properly.

2 Likes

Thank you guys so much ! But im using Pastel messaging template and nothing I want to do seems to work with its structure so I will have to create my own messaging system, before proceeding!

Yes, Pastel is more optimised for ā€œreal timeā€ style messages.

What I have done in the past is add a ā€œreadā€ field to message. And then use this, and the Conversation table, to do notifications.

mess1

And then set the ā€œread flagā€ across the messages in the conversations.

mess4

As a note, this will not work very well if you have multiple recipients for a message (so Whatsapp group style). I would really start again with a new structure if you can.

4 Likes

Thank you ! But my motivation is currently very low because all my issues are messenger system later so I will take care of this later :sweat_smile:

Hello @NigelG,

I am currently working on a couple of apps so have been looking around learning different things within bubble.

I too have an app that would require some form of notification system, which led me to this post. I understand the workflow section of this but what is the first section ā€˜Buttons searching for messagesā€ about and how are you using it? Does a user click it, is it hidden and runs in the background etc? Or it just showing the number of messages unread?

I just got the pastel template to look at so I could follow this, but there isnā€™t any button in the template. I would like to try and get this to work so I can use a form of the template as a ā€˜live messagingā€™ system.

Sorry for the lack of understanding, or if Iā€™m asking too much but as I said Iā€™m learning the ropes.

Edit

Donā€™t worry about answering that now, Iā€™ve worked it out but as you said pastel isnā€™t the best for doing it with. But now I know I shall begin designing something of my own :+1:t2:.

Thanks,

Mike

2 Likes

I put together something where my database has a datatype of messages. There is a datafield of UnReadMessages which is a list of users; I believe I saw this on one or two other templates of messenger apps.

Either way the UnReadMessages will have users added or removed based on workflows indicating their presence in the current chat. The chat is actually a conversation datatype which has a list of messages as a datafield. On the page it is a RG set to messages as type and datasource is current pageā€™s conversation as the user needs to navigate to the chat page from the page that has their list of conversations. The conversation they click on has itā€™s data sent to the chat page.

To display the number of unread messages a user has when they log in to see their list of conversations and the number of messages from that conversation they are marked as unread on I set a text element to have an appearance of the following:

Current Cellā€™s Conversationsā€™s Message List filtered:count

The filter is set to UnReadMessages contains current user

This way you donā€™t need to do a search for messages or anything that would possible slow down the app.

4 Likes

Such a simple solution, thanks! I wouldnt have thought of this, i was on my way to create notifications for every new message, thanks for helping me avoid this :slight_smile:

If you want a real notification system that allows the user to navigate to the conversation and the new message you should set up your workflows for when the notification is clicked to navigate to your messenger page and send URL parameters to indicate which conversation to open so they can be brought directly to the new message.

How do you do this if you want the notification to appear on a different page than the messaging page? Because in that situation you canā€™t do a search for messages

1 Like

Please do you have any video tutorial on how to do this?

I do not.

You may find a free messaging template that maybe has it put together. Or search youtube for a video. Iā€™d search using a term like ā€˜bubble.io notificationsā€™

1 Like

Exactly my problem now!

Did anyone find out how to set up a notification say from your home page to highlight you have an unread message? Iā€™m
Wanting to change the colour of my ā€œmessagesā€ tab on all other pages when current user gets a new message that is unread but struggling to configure this as other pages donā€™t have the message data type

Iā€™m in the same position as you. Iā€™ve managed to get it to change colour, but not to stay that new colour when I change to another page.

Any luck?

No sorry iv had no luck but have put it to one side in the hope someone came back on here or I could work it out after a break