I am working with react native wrapper for Google Cast SDK and I couldn't send a message from the sender to receiver. I am able to cast media or pause and resume it. The problem is only about custom messages. My custom message listener is never called in the receiver side. Should the message have a specific structure that I am missing? Thanks in advance.
Sender:
GoogleCast.initChannel('urn:x-cast:testChannel');
GoogleCast.sendMessage('urn:x-cast:testChannel', 'testMessage');
Receiver:
const context = cast.framework.CastReceiverContext.getInstance();
const CUSTOM_CHANNEL = 'urn:x-cast:testChannel';
context.addCustomMessageListener(CUSTOM_CHANNEL, function(customEvent) {
// handle customEvent.
console.log('event received');
});
Edit: I am able to send message from receiver to sender:
Receiver:
context.sendCustomMessage(CUSTOM_CHANNEL , undefined, 'myMessage');
Sender:
GoogleCast.EventEmitter.addListener(GoogleCast.CHANNEL_MESSAGE_RECEIVED, ({undefined, message}) => {
console.log(message);
});
I think this is problem bellow
https://issuetracker.google.com/issues/117136854#comment7
So try this...
Send
and Receiver