【发布时间】:2020-07-22 22:35:35
【问题描述】:
我正在用 Nativescript angular 构建一个金融应用程序。我需要一些参考资料,比如如果应用程序在设置了一些空闲超时后在后台打开并运行,它应该重定向到我们指定的页面。我无法在 Nativescript 中获得正确的参考,任何人都可以为空闲超时添加解决方案。我检查了 Nativescript 扩展活动,但无法正确获取
【问题讨论】:
我正在用 Nativescript angular 构建一个金融应用程序。我需要一些参考资料,比如如果应用程序在设置了一些空闲超时后在后台打开并运行,它应该重定向到我们指定的页面。我无法在 Nativescript 中获得正确的参考,任何人都可以为空闲超时添加解决方案。我检查了 Nativescript 扩展活动,但无法正确获取
【问题讨论】:
您应该从阅读文档开始。你需要的是生命周期钩子。
阅读:https://docs.nativescript.org/angular/core-concepts/application-lifecycle#use-application-events
applicationOn(suspendEvent, (args: ApplicationEventData) => {
setTimeout(() => {
// do what you want after a certain amouont of time
// don't
}, 5000);
});
或
applicationOn(resumeEvent, (args: ApplicationEventData) => {
// compare current datetime with the last datetime saved in suspendEvent event
});
不要忘记您的应用可能会被强制关闭,因此您必须根据自己的需要处理此问题
【讨论】: