在Cordova和Ionic中检测屏幕的开

在Cordova和Ionic中检测屏幕的开

本文介绍了在Cordova和Ionic中检测屏幕的开/关的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想检测手机何时被锁定和解锁.

I want to detect when the phone is locked and unlocked.

计划是在手机解锁时显示(非广告)弹出窗口.到目前为止,Cordova似乎仅支持暂停和恢复事件,而这并不能为我提供所需的功能.

The plan is to display a (non-Ad) popup when the phone is unlocked. So far Cordova seems to only support pause and resume events which will not get me the functionality that I need.

Native Android支持屏幕开/关和用户提示事件.是否可以使用这些事件,如果不能,则可以构建一个插件来获得相同的功能?

Native Android supports screen On/Off and User Present events. Is it possible to use these events and if not is it possible to build a plugin to gain that same functionality?

谢谢.

推荐答案

对于android,您将必须使用此插件模板创建后台服务,以便您可以侦听这些事件:

For android you will have to use this plugin template to create a background service so you can listen for those events:

https://github.com/Red-Folder/bgs-sample

在iOS上,如果最终要在iOS上进行部署,则已经有一个插件已经实现了此功能:

On iOS there is a plugin that already implements this functionality if you will eventually deploy on iOS:

https://github.com/ttatarinov/lock-screen-logger- phonegap-plugin

这篇关于在Cordova和Ionic中检测屏幕的开/关的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 20:54