Lightning Message Service Methods for Lightning Experience

These three methods allow your CTI implementation to communicate with other Visualforce, Aura, and Lightning components that also use the Lightning Message Service. The subscribe method attaches a listener function to a specified Lightning Message Channel. The publish method lets you send a message on a Lightning Message Channel. The unsubscribe method lets you remove listener functions you added with the subscribe method.

These methods are available in API version 47.0 or later.

These methods can be used only with Lightning Experience. They can be used in iFrame and Visualforce components.

The subscribe method allows you to attach a listener function to a specified Lightning Message Channel. Lightning Message Service calls your listener function with the message that a component sends.

NameTypeDescription
channelNamestringThe name of the Message Channel that you can subscribe to.
listenerfunctionJavaScript method that’s called when a message is sent on the Message Channel.
callbackfunctionJavaScript method that’s executed when the API method call is completed.
NameTypeDescription
subscriptionobjectThe subscription from which you can remove the listener function.
callbackfunctionJavaScript method that’s executed when the API method call is completed.
NameTypeDescription
channelNamestringThe name of the Message Channel that you can subscribe to.
messageobjectSerializable JSON object that is sent on the Message Channel.
callbackfunctionJavaScript method that’s executed when the API method call is completed.