Hi, Even I’m facing the same doubt ? any solution you found ?
No, I did not find a solution else
You are also facing issues on receiving notifications when app is killed in Android 8 and above ?
No, I believe that we don’t have the same problem, in my case I don’t receive any notification, I want simply that my application keep running even if the screen is sleeping. There is no error in my code but I want to apply the @boltex’s solution but it doesn’t work and I don’t know where I must put the code above
please, help me… where I should implement this code:
if( ionic.Platform.isAndroid() ){
cordova.plugins.backgroundMode.enable();
window.powerManagement.dim(function() {
console.log('Wakelock acquired');
}, function() {
console.log('Failed to acquire wakelock');
});
window.powerManagement.setReleaseOnPause(false, function() {
console.log('setReleaseOnPause successfully');
}, function() {
console.log('Failed to set');
});
}
initializeApp() {
this.platform.ready().then(() => {
this.powerManagement.dim().then(
res => console.log('Wakelock acquired'),
() => {
console.log('Failed to acquire wakelock');
}
);
this.powerManagement.setReleaseOnPause(false).then(
res => console.log('setReleaseOnPause successfully'),
() => {
console.log('Failed to set');
}
);
this.statusBar.styleDefault();
this.splashScreen.hide();
});
}
You can put it in app.component.ts ( I am using v4 )
I put code here, and edit. My screen didn’t close but background app still work like 5 mins. It is not a completely solution for Android v8.
Hi! How did you import the power management app? I get this error
Property ‘powerManagement’ does not exist on type ‘MyApp’