How can social media web apps determine if your page is on screen vs minimized?
Here's an example: Whatsapp Web tells people that you're online if your page is open and on screen. It also does not load chats if it is minimized. How do I make it think that it is on screen. I would like some Javascript code that I can inject into my UIWebView (iOS) so that it keeps loading chats even when the UIWebView is on the background. Or some other solution to the problem.
What happens right now is that when I open a chat, it loads the last message and has a loading icon on top until I actually open the app. Only once I open the app, it loads the rest of the messages.
EDIT: From one of the answers, I think I should be running a code similar to this:
document.focus();
Still does not load the rest of the chat unless on screen.