Note :- platform.ready() is the trick ,
put the code inside platform.ready() function
constructor(private platform: Platform,private backgroundMode: BackgroundMode){
platform.ready().then(() => {
console.log("background mode off")
this.backgroundMode.enable();
console.log("background mode check",this.backgroundMode.isActive(), this.backgroundMode.isEnabled(),this.backgroundMode.isScreenOff);
// this.backgroundMode.enable();
console.log("-------------------->", this.backgroundMode.isEnabled());
console.log("-------------------->", this.backgroundMode.isActive());
this.backgroundMode.on("activate").subscribe(()=>{
console.log("background mode on");
});
});
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…