+ Start a Discussion
ArabindaArabinda 

Private Messages Notification in Community Site

Hi ,
I am trying to show some notification for unread private message in a VF page of Community Site.
In standard chatter page it used to notify the number of unread mails side by Messages link.

I did some search regarding this but didn't get clear idea how to achieve this.
Please suggest some ideas how I can know that a user has some unread private messages or how I can show similar functionality as of standard chatter page in VF page.


Thanks
Arabinda
Best Answer chosen by Arabinda
Ashish_SFDCAshish_SFDC
Hi Arabinda, 


See the class methods below, 

ChatterMessages Class

ConnectApi
Usage
Use Chatter in Apex to get, send, search, and reply to messages. You can also get and search conversations, mark conversations as read, and get a count of unread messages.

getUnreadCount()
Returns the number of conversations the context user has marked unread. If the number is less than 50, it will return the exact unreadCount, and hasMore = false. If the context user has more than 50, unreadCount = 50 and hasMore = true.
getUnreadCount(String)
Returns the number of conversations the context user has marked unread across their available communities. If the number is less than 50, it will return the exact unreadCount, and hasMore = false. If the context user has more than 50, unreadCount = 50 and hasMore = true.
markConversationRead(String, Boolean)
Marks a conversation as read for the context user.
markConversationRead(String, String, Boolean)
Marks a conversation as read or unread for the context user across their available communities.

https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_ConnectAPI_ChatterMessages_static_methods.htm


Regards,
Ashish

All Answers

Ashish_SFDCAshish_SFDC
Hi Arabinda, 


See the class methods below, 

ChatterMessages Class

ConnectApi
Usage
Use Chatter in Apex to get, send, search, and reply to messages. You can also get and search conversations, mark conversations as read, and get a count of unread messages.

getUnreadCount()
Returns the number of conversations the context user has marked unread. If the number is less than 50, it will return the exact unreadCount, and hasMore = false. If the context user has more than 50, unreadCount = 50 and hasMore = true.
getUnreadCount(String)
Returns the number of conversations the context user has marked unread across their available communities. If the number is less than 50, it will return the exact unreadCount, and hasMore = false. If the context user has more than 50, unreadCount = 50 and hasMore = true.
markConversationRead(String, Boolean)
Marks a conversation as read for the context user.
markConversationRead(String, String, Boolean)
Marks a conversation as read or unread for the context user across their available communities.

https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_ConnectAPI_ChatterMessages_static_methods.htm


Regards,
Ashish
This was selected as the best answer
ArabindaArabinda
Hi Ashish,
The idea you gave really helped me.I have implemented it and its working properly.
Thanks a lot for your help.

Thanks
Arabinda
Daniel B ProbertDaniel B Probert
Hi Arabinda,

Any chance you can share your workings I have a simple component I have built that is using the getUnreadCount but it always comes back with the value of 0 even through I know there messages.

Thanks
Dan