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!