function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Daniel B ProbertDaniel B Probert 

getunreadcount in Community Returning 0

I am trying to build a simple live notification lightning component for when a new private message is received. That way when you're on the community you don't rely on having to click into messages to see there is a new message.

My problem is that always returns a value of 0

Class:
 
public class CAMAComm_Notifications {
	
    @AuraEnabled
    public static integer getUnreadCount(){
        ConnectApi.UnreadConversationCount unreadMessageCount = ConnectApi.ChatterMessages.getUnreadCount();
		Integer numberOfUnreadMessages = unreadMessageCount.unreadCount;
        return numberOfUnreadMessages;
	}
}

my lightning cmp:
 
<aura:component implements="forceCommunity:availableForAllPageTypes" controller="CAMAComm_Notifications" access="global" >
    <aura:attribute name="unreadmessagecount" type="Integer"/>
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
    		<div class="slds-notify_container">
  				<div class="slds-notify slds-notify--alert slds-theme--success" role="alert" style="position: inherit !important;">
	    			<span class="slds-assistive-text">Success</span>
    				<p>{!v.unreadmessagecount} unread messages</p>
				</div>
			</div>    
	
</aura:component>

my controller js
 
({
    doInit : function(component, event, helper) {
        helper.messageCountpoller(component, event, helper);
    }
})

my helper js
 
({
    messageCountpoller : function(component, event, helper) { 
        helper.callApexMethod(component,helper);
        
        //execute callApexMethod() again after 5 sec each
        window.setInterval(
            $A.getCallback(function() { 
                helper.callApexMethod(component,helper);
            }), 5000
        );      
    },
    handleResponse : function (response, component){
        var retVal = response.getReturnValue();
        console.log('Number of Messages: ' + retVal);
        component.set("v.unreadmessagecount",retVal); 
    },
    callApexMethod : function (component,helper){    
        var action = component.get("c.getUnreadCount");        
        action.setCallback(this, function(response) {
            this.handleResponse(response, component);
        });
        $A.enqueueAction(action); 
    } 
})
from everything i can see this is in line with the documentation for the getUnreadCount() however it will never display anything but 0.

are private messages not supported using this method? If not how else can I do it?

cheers
dan