When using react native google cast I'm trying to send a custom message for casting my web page by setting my custom reciver ID in the app.json. But when i connect to the chrome cast it establishes a succesful connection and "sends the message" but nothing gets sent through
import React, { useEffect } from 'react';
import { CastButton, useRemoteMediaClient, useCastChannel } from 'react-native-google-cast';
export default function ChromeCast() {
const channel = useCastChannel('urn:x-cast:com.url.cast', message => console.log('Received message', message));
const client = useRemoteMediaClient();
useEffect(() => {
const loadReceiverUrl = async () => {
try {
if (client && channel) { // Check if both client and channel are available
//Initial Image before Scoring Page
await client.loadMedia({
mediaInfo: {
contentUrl: 'https://sportyapp.co.za/assets/images/SportyAppLoading.png',
}
});
// Send message to the channel
if (client && channel.sendMessage) {
channel.sendMessage({
"media": {
"contentId": "body",
"contentUrl": "https://sportyapp.co.za/scoreapi.php?view=tv&layout=99&stream_url=0a897bf3-377e-5bfd-8f4e-a70bdf23cdf7.local&target=0a897bf3-377e-5bfd-8f4e-a70bdf23cdf7.local",
},
"credentials": "SportScreen"
});
console.log('Message sent');
} else {
console.error('sendMessage method is not available on the channel object.');
}
}
} catch (error) {
console.error('Error loading custom receiver URL:', error);
}
};
loadReceiverUrl();
return () => {
// Clean up any resources if needed
};
}, [client, channel]);
return <CastButton style={{ width: 24, height: 24, tintColor: 'blue', marginRight: 20 }} />;
}
So ive tried teh following but when it runs it just comes with a blacnk screen with the cast logo in the middle, im guessing indicating there is no media that has been loaded but before that it shows a progress bar that loads up to 50% and then goes away to a blank no content screen