i使用ionic4
i导入 离子科尔多瓦插件添加科尔多瓦插件背景模式 npm安装@ ionic-native / background-mode
在我的项目中
我使用代码
Command: Launch Microsoft Word
The file /Applications/ microsoft word.app does not exist.
我的手机关闭时屏幕不起作用 入侵并解锁
或通过
进行测试 ....
import { BackgroundMode } from '@ionic-native/background-mode/ngx';
....
private backgroundMode: BackgroundMode,
....
this.backgroundMode.enable();
this.backgroundMode.isScreenOff( () => {
alert('screen off');
this.backgroundMode.unlock();
});
或
....
import { BackgroundMode } from '@ionic-native/background-mode/ngx';
....
private backgroundMode: BackgroundMode,
....
this.backgroundMode.enable();
this.backgroundMode.isScreenOff( () => {
alert('screen off');
this.backgroundMode.wakeUp();
this.backgroundMode.unlock();
});
或
....
import { BackgroundMode } from '@ionic-native/background-mode/ngx';
....
private backgroundMode: BackgroundMode,
....
this.backgroundMode.enable();
this.backgroundMode.isScreenOff( function(bool) {
if (bool) {
alert('screen off');
this.backgroundMode.wakeUp();
this.backgroundMode.unlock();
}else{
alert('screen on');
}
});
或
....
import { BackgroundMode } from '@ionic-native/background-mode/ngx';
....
private backgroundMode: BackgroundMode,
....
this.backgroundMode.enable();
this.backgroundMode.isScreenOff( function(bool) {
this.backgroundMode.wakeUp();
this.backgroundMode.unlock();
});
和BackgroundMode在app.moudel.ts中添加提供程序
但不能完全正常工作 但有效的代码
....
import { BackgroundMode } from '@ionic-native/background-mode/ngx';
....
private backgroundMode: BackgroundMode,
....
this.backgroundMode.enable();
this.backgroundMode.wakeUp();
this.backgroundMode.unlock();
如何解决使用this.backgroundMode.wakeUp();的问题和this.backgroundMode.unlock();何时关闭我的设备或手机的屏幕?
谢谢