I found a solution for some regular background activity!

I have installed both the background mode and the power management plugin. I want to call a function daily on a spcific time. It works when the app in background. If i closed the app, the background service not running. The background service running only when the app in background.

Please be more precise, what do you mean exactly?

I am developing an employee management app. In that i have to trigger on e function at 9 O’Clock to signin automatically.It should work even the app not running. To achieve this i want to run the app in background.

Yes, the app needs to be in the background. If you completely close the application, (By killing it in the app manager) then it will not do anything.

@boltex … I’m trying to do a upload of the photo and some information to server like the way of uploading a photo in facebook…but while uploading ,if the app is closed it is failed…Can you please help me how to achieve this even when they close the application while uploading. your plugin is working when the app is in background. But i want to run that even when the app is close

@boltex Could you provide a full example? Thank in advance.


??? any solution ???

Hi there

When I am using this code in my app its giving me below error

Warning: Uglification failed.
Unexpected token punc «;», expected punc «,».

Its showing at the 2nd last line of the code!
Any idea why its giving syntax error?

hello @simo i fetching same issue did you solved it ???
please help me… thanks

hello @nakulkundaliya i modified the java files in this plugin “cordova-plugin-mauron85-background-geolocation” to achieve my goal but just in android.
if u want this plugin after modification i will be uploaded for you.
sorry for bad english :stuck_out_tongue:

Thanks for replay
Can you paste modification code here???

plugin : https://ufile.io/2a922
uncompress this file in the folder “com” in cordova-plugin-mauron85-background-geolocation plugin
Most of the changes in the file LocationService.java

Any help I am in the service

Hi @Simo2015,

Link has been expired ,could you please send it again

Hi @boltex, I’m wondering where I should put the following 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’);
});

I want to know the path of the directory and the file I must put this code.

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.