Reputation: 740
In my react project have visibility.js package imported, which I am using to re-render page if user opens web view from background and more then 5 min is passed, inside one of my hook I have simple implementation:
useEffect(() => {
let initialTime = 0
const limit = 5 * 60 // 5 min.
const listener = Visibility.change(function (e, state) {
if (Visibility.hidden()) {
initialTime = (new Date().getTime()) / 1000
} else {
const currentTime = (new Date().getTime()) / 1000
updatePage()
}
}
})
return () => {
Visibility.unbind(listener)
}
}, [])
This is working if you open in 10 min, 1 hour or so, but noticed that it doesn't work after a long time leaving the web in the background, like overnight... I am testing on IPhone 12, V14.6. Did some research, but couldn't find any ideas on this particular case, maybe someone had the same issue and can share your experience, thanks.
Upvotes: 1
Views: 54