How to handle background mode on open modal

I am developing a geolocation application which should record the position and send it even when it is in the background.
I use the modules




Everything seems to be working properly but when I open a modal or use the camera the background is automatically activated.

Is there any way to handle this behavior?

thanks in advance

Are you using iOS or android? When you say modal, are you using Ionic’s modals or a native plugin?

If your ussing android and opening a camera, this is technically correct. As android treats this as different activities and processes. So opening the camera calls the camera app, vs overlaying a camera view within the main app.

I’d see if there are different event details here that you could inspect, or wait before actually calling any utils in the background process.

thanks for reply
I use ionic-angular modal and the behavior seems present only in Android.
I have the same problem wih system modal for permission request.

I tried to block my background operations when I open modals or request system permissions but I’m a little confused by the behavior of the app.

disabling background mode during open modals o camera, files chooser, etc… with:


and re-enabling it at the end of the procedure with:


may be a correct procedure?

I can’t understand the background mode behavior…
I initialize the background mode with this code:

  backgroundServiceInit(): boolean {
    let self=this;
    try {
      self.backgroundMode.setDefaults({ silent: false });

      this.backgroundMode.on('activate').subscribe(() => {
          self.logProvider.handleLog('log', 'debug', 'AppStatusProvider backgroundMode.on(activate)!!!');

      this.backgroundMode.on('deactivate').subscribe(() => {
        self.logProvider.handleLog('log', 'debug', 'AppStatusProvider backgroundMode.on(deactivate)!!!');

      this.backgroundMode.on('failure').subscribe(() => {
        self.logProvider.handleLog('log', 'debug', 'AppStatusProvider backgroundMode.on(failure)!!!');

      self.platform.pause.subscribe(() => {
      return true;

    } catch (e) {
      this.logProvider.handleLog('log','debug','AppStatusProvider backgroundServiceInit ERROR', e.message);
      return false;

it’s should be disabled but when the camera app is open the activate event is generated.

wat’s is wrong?