Closed monizb closed 1 year ago
Hi Monish, sorry about the delayed response. You can access the sendChannelMessage
method from the RtmContext
like you mentioned. Here's a snippet:
let MyComp = () => {
const { sendChannelMessage } = useContext(RtmContext)
return (
<div onClick={() => sendChannelMessage({ messageType: 'RtmDataRequest', type: 'ping' })}>
send
</div>
)
}
You can inject the component like so:
<PropsContext.Provider value={{
rtcProps: {
appId: APP_ID,
channel: 'test',
}}}>
<TracksConfigure>
<VideocallUI />
<MyComp />
</TracksConfigure>
</PropsContext.Provider></>
If you can describe the use-case, I'll update the messageObject
type to add a user customizable type that can be used to send custom messages in a future update, I think there's scope to add more flexibility with sending messages.
closing due to inactivity
I am trying to integrate Agora UI Kits into my react app, the connection part works and I am able to connect to both RTM and RTC channels, now I want to be able to send a message to everyone in the channel, I see there is a "sendChannelMessage" method under "RtmContext" in the library but I am unable to figure out how to import and use this method? Even if I import RtmContext it doesn't seem to expose the sendChannelMessage method somehow? Please help me, thanks!
I tried referring to this: https://agoraio-community.github.io/Web-React-UIKit/interfaces/_internal_.rtmContext.html#sendChannelMessage but I'm unable to understand how to import this into React