I need store another state basically same as CometChat.markAsRead (but it's already used)

Can I set some state (basically boolean - true/false) for the received message? Something like markAsRead, but should be applied only for one message.

Hello @dimaportenko,

Can you please elaborate more on what you are trying to achieve so that we can understand your requirement and help you achieve the same.

Warm Regards,

CometChat Pro
Mayur Bhandari

@mayur.bhandari I have list of ‘Notifications’ (CustomMessage). Each notification have 2 states like read/unread which I can change by tap. Currently, I’m store this state locally. It has some drawbacks, like loose state on reinstall.

Hello @dimaportenko,

Are these Notifications (CustomMessage) will be logged-in user’s messages or can they be from other users as well? I mean the sender of these custom messages will be the logged-in user or can be any other user as well?

Warm Regards,

CometChat Pro
Mayur Bhandari

@mayur.bhandari I think it’s a logged-in user. I have to reach out to another team to find out. Can you please explain both cases?

Hello @dimaportenko,

If those messages are of the logged-in user (i.e sender of the message is the logged-in user) you can update the custom data of the custom message with the current state. You can read more about editing a message here.

Else if those messages can be of any other user, then you will need to maintain a list of these notifications with their current state in the logged-in user’s metadata inside the @private key. Anything stored inside the @private key is only visible to the logged-in user and no other user can access that detail.

To update a user you can use the updateUser(). This method takes two parameters, a user object & authKey. Using this method you can update any user. You can read more about updateUser() here.

We are currently working on adding a new method named updateCurrentUserDetails(). This method takes only a parameter as a user object. Using this method you can only update the logged-in user.

Warm Regards,

CometChat Pro
Mayur Bhandari

As I can see it’s possible to edit only if I sender of the message, but in this case I’m the receiver. So I suppose only the second option with updateUser is applicable here.

Hello @dimaportenko,

Yes, that is why I asked if the custom messages will be sent by the logged-in user only or the sender can be any other user. Anyway, I hope this solves your query.

Please let us know if you have any other questions regarding this query. If not then I will go ahead and close this ticket.

If you face any other issues or have any other queries you can always create a new ticket.

Have a good day. Thank You

Warm Regards,

CometChat Pro
Mayur Bhandari

I’ll try the suggested solution and put my update here.

1 Like

The user metadata option works like a charm. Thank you @mayur.bhandari!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.