You need to sign in to do that
Don't have an account?
Kolli
My Requirement:- we want display to the notifications without reloading the page and with out any streaming api. if any change happen on the record from custom lightning page.
I have done some R&D. then i found something like PlatformEvents and empApi Components. I tried two scenario's Created One platform Event Object. 1)Publishing the notification from Process Builder and able to get notifications in Bell Icon. 2)Publishing the Notification from process builder.For Subscribing the event, created lightning component with help "empAPI component" and added my component to a lightning page, then i can able to see the notification in cosnole. But if add the same component into Lightning Application, not able to see the notifications.
i guess event not subscribing, little confusing. Below is the code snippet.
Component:-
Controller:-
({ init : function(component, event, helper) { alert('init() calling');
var empApi = component.find("empApi"); var errorHandler = function (message) { console.log("Received error ", message); }.bind(this); empApi.onError(errorHandler);
var channel='/event/Custom_Notification__e'; var sub; var replayId=-1;
var callback = function (message) { component.find('notifLib').showToast({ "title": "Message Received!", "message": message.data.payload.Notification_Title__c });
console.log("Notification Title>>>>>>" + message.data.payload.Notification_Title__c); }.bind(this); empApi.subscribe(channel, replayId, callback).then(function(value) { console.log("Subscribed to channel " + channel); sub = value; component.set("v.sub", sub); }); } })
Lightning App:-
<aura:application extends="force:slds">
<aura:dependency resource="markup://force:*" type="EVENT"/>
<c:PESubscribe2/>
</aura:application>
Could you please help any one.
Thanks
unable to subscribe platform events using "lightning:empApi" in lightning component
My Requirement:- we want display to the notifications without reloading the page and with out any streaming api. if any change happen on the record from custom lightning page.
I have done some R&D. then i found something like PlatformEvents and empApi Components. I tried two scenario's Created One platform Event Object. 1)Publishing the notification from Process Builder and able to get notifications in Bell Icon. 2)Publishing the Notification from process builder.For Subscribing the event, created lightning component with help "empAPI component" and added my component to a lightning page, then i can able to see the notification in cosnole. But if add the same component into Lightning Application, not able to see the notifications.
i guess event not subscribing, little confusing. Below is the code snippet.
Component:-
Controller:-
({ init : function(component, event, helper) { alert('init() calling');
var empApi = component.find("empApi"); var errorHandler = function (message) { console.log("Received error ", message); }.bind(this); empApi.onError(errorHandler);
var channel='/event/Custom_Notification__e'; var sub; var replayId=-1;
var callback = function (message) { component.find('notifLib').showToast({ "title": "Message Received!", "message": message.data.payload.Notification_Title__c });
console.log("Notification Title>>>>>>" + message.data.payload.Notification_Title__c); }.bind(this); empApi.subscribe(channel, replayId, callback).then(function(value) { console.log("Subscribed to channel " + channel); sub = value; component.set("v.sub", sub); }); } })
Lightning App:-
<aura:application extends="force:slds">
<aura:dependency resource="markup://force:*" type="EVENT"/>
<c:PESubscribe2/>
</aura:application>
Could you please help any one.
Thanks
Component:-
<aura:component implements="flexipage:availableForAllPageTypes" access="global" >
<aura:handler name="init" value="{!this}" action="{!c.init}" />
<aura:attribute name="sub" type="map" />
<lightning:empApi aura:id="empApi" />
<lightning:notificationsLibrary aura:id="notifLib"/>
</aura:component>