6

I need to add bell notifications to a Community using Napili template.

I tried to search if there is an OOTB Lightning Component but I did not found anything.

Anyone knows if exists a open source or free bell notification component ?

enter image description here

6

You should be able to use lightning:icon in your component, as follows:

<lightning:icon iconName="utility:notification" />

This is also in the standard SLDS library if you're using the static resource version of SLDS, located under utility/notification.png or the svg version at /assets/icons/utility-sprite/svg/symbols.svg#notification

  • i mean, i need the funcionality, not just the icon – ransommule Jan 2 '17 at 19:25
  • @ransommule Hmm. I don't know of any such component, and I couldn't find anything, but I don't think it'd be too hard to write one. – sfdcfox Jan 2 '17 at 19:38
4

UPDATE:

Since Winter 17
forceCommunity:notifications https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/aura_compref_forceCommunity_notifications.htm#!

Finally, I found that what I wanted is something like this :

MARKUP

    <span class="counterLabelContainer" aura:id="divNotificationCount">
        <span class="counterLabel">{!v.unreadNotifications}</span>
    </span>            
</ui:button>

CONTROLLER

retrieveNotifications : function(objComponent) {
        var objControllerAction = null;
        var arrFeedElements = null;
        var intUnreadNotifications = 0;
        var objNotificationList = null;
        var strState = null;
        var objNotifications = null;
        var strHTML = null;

        objControllerAction = objComponent.get("c.getNotifications");
        objNotificationList = objComponent.get("v.NotificationElements");
        objControllerAction.setCallback(this, function(objResponse) {           
            strState = objResponse.getState();

            if (objComponent.isValid() && strState === "SUCCESS") {
                arrFeedElements = objResponse.getReturnValue();
                if(arrFeedElements != null && arrFeedElements.length != null) {
                    intUnreadNotifications = arrFeedElements.length;
                    objComponent.set("v.unreadNotifications", intUnreadNotifications);

                    objNotifications = objComponent.find("divNotificationCount");

                    if(intUnreadNotifications > 0) {
                        $A.util.removeClass(objNotifications, "counterLabelContainerHidden");
                        $A.util.addClass(objNotifications, "counterLabelContainer");

                        strHTML = '';
                        for(var intIndex = 0; intIndex < intUnreadNotifications; intIndex++) {
                            strHTML += this.createNotificationRow(arrFeedElements[intIndex]); 
                        }

                        document.getElementById('NotificationElements').innerHTML = strHTML;

                    }                 
                } 
            } else {
                console.log("Failed with state: " + strState);
            }
        });
        $A.enqueueAction(objControllerAction);
    },

APEX CALL

    @AuraEnabled
public static List<ConnectApi.FeedElement> getNotifications() {
    ConnectApi.Community objCommunity = null;
    CECC_Community_Settings__c objConfig = null;
    List<ConnectApi.FeedElement> lstNews = null;
    ConnectApi.FeedElementPage objPage = null;

    objConfig = CECC_HelperFunctions.retrieveConfig();
    objCommunity = CECC_HelperFunctions.retrieveCommunity(objConfig.Portal_Name__c);        

    objPage = ConnectApi.ChatterFeeds.getFeedElementsFromFeed(objCommunity.Id, ConnectApi.FeedType.News, 'me');

    if(objPage != null && objPage.elements != null && objPage.elements.size() > 0) {
        lstNews = objPage.elements;
    }

    return lstNews;
}  

UPDATE:

Since Winter 17
forceCommunity:notifications https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/aura_compref_forceCommunity_notifications.htm#!

protected by Community Jan 2 at 18:59

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.