admin管理员组文章数量:1289928
Capacitor provides an App plugin that allows to get a call back when the application goes background or foreground. But how to get the application isActive
value (a.k.a. foreground/background state) at any moment? The problem is that I don't know the application state until I subscribe to the appStateChange
event AND the app goes background or foreground.
Capacitor provides an App plugin that allows to get a call back when the application goes background or foreground. But how to get the application isActive
value (a.k.a. foreground/background state) at any moment? The problem is that I don't know the application state until I subscribe to the appStateChange
event AND the app goes background or foreground.
- 1 I've reported a feature request to Capacitor developers: github./ionic-team/capacitor/issues/2500 – Finesse Commented Feb 28, 2020 at 1:25
2 Answers
Reset to default 8A method to get the current state was added recently:
import {Plugins} from '@capacitor/core';
const {App} = Plugins;
let {isActive} = await App.getState();
document.hasFocus()
This will return a boolean. If the tab the web-app is in has the focus then it will return true
else it will return false
source: https://developer.mozilla/en-US/docs/Web/API/Document/hasFocus
本文标签: javascriptHow to check if the application is foreground or background nowStack Overflow
版权声明:本文标题:javascript - How to check if the application is foreground or background now? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741454094a2379655.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论