Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS UiWebView / Page Visibility Api: "pageshow" event not firing

I am trying to use the Page Visibility Api to detect when web content is being shown in iOS. I have simple JS:

    window.addEventListener("pageshow", function(){
        alert("page shown");
    }, false);

The alert fires as expected in mobile safari when the tab is made active, or when safari is minimized and then re-shown.

However if I host the web content in a UiWebView, the event is not firing. Has anyone else encountered this issue? If so any work around for this?

Thanks...

like image 727
user3562551 Avatar asked Apr 23 '14 00:04

user3562551


1 Answers

The UIWebView dose not support that event however you could look into triggering the event your self from the app natively

This how you call a JavaScript function from Objective-C Objective C send data to phonegap and call javascript function

Then you just use the code above to notify the webview when your handling the application being started or restarted from suspension

Objective C: How to check if application is currently active (i.e. user is using it)? should help with that

like image 189
Barkermn01 Avatar answered Sep 21 '22 01:09

Barkermn01