I completely agree with the answer above. Even though the pageVisibilityChange event cannot be fired in UIWebview. you can still detect it by your own code, and then notify JS using JS-bridge technology or JS-binding.
There is another method to achieve this setInterval function. You can initialize the variable for the current timestamp at the beginning of the application’s lunch, and then increase this variable by one second in each interval callback function. you need to compare the current timestamp with this variable, if they have a difference of one second, this means that the setInterval callback has been blocked! This way you can indicate that the page has gone out in the least number of seconds of servlets.
source share