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
You can use socket.io to have server pushing datas to webview application.
Take a look at the get started of socket.io website : https://socket.io/get-started/chat
Tell if you have questions.