I am creating a View which displays a local webpage which also has styles and JavaScript using a WKWebView.
I want to send data every second from WebView using node js like this
const timerEventEmitter = new EventEmitter();
timerEventEmitter.emit("update");
let currentTime = 0;
// This will trigger the update event each passing second
setInterval(() => {
currentTime++;
timerEventEmitter.emit('update', currentTime);
}, 1000);
timerEventEmitter.on('update', (time) => {
console.log('Message Received from publisher');
console.log(`${time} seconds passed since the program started`);
});
Can i send the log
{time} seconds passed since the program started
to native ios app, or send data using react like this