Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The plugin does not work in the background for more than 30 minutes #497

Open
JessicaMouta opened this issue Feb 6, 2020 · 8 comments
Open

Comments

@JessicaMouta
Copy link

The plugin does not work in the background for more than 30 minutes. My code is this:
init() {
this.platform.ready().then(() => {
this.activeBackgroundMode();
this.powerManagement.dim();
this.powerManagement.setReleaseOnPause(false);
});
}
activeBackgroundMode(){
this.backgroundMode.enable();
this.backgroundMode.on('activate').subscribe(() => {
this.backgroundMode.disableWebViewOptimizations();
this.backgroundMode.disableBatteryOptimizations();

    this.activePolling();

  });

already updated the plun but contained not working.

Can someone help me!!

@pimol
Copy link

pimol commented Feb 6, 2020

In attach a simple test (.ts and .html files) I used to test the plugin with Android 8 and 9.
Simply, it run a counter so you can see if it works in background or not.

I hope it help.
home.page.zip

@JessicaMouta
Copy link
Author

The problem is it seems that the plugin works only for a while, in my tests it lasted up to an hour, but then it closes .. my app needs to do a pooling to keep a company online and receive orders.

a function: this.bkgng.moveToBackground();
makes any difference?

@phpfile
Copy link

phpfile commented Feb 8, 2020

Make sure you don't disable the running notification.
Don't use this:
cordova.plugins.backgroundMode.setDefaults({ silent: true });

@ersaurabh101
Copy link

Hey,

Did you find something which keeps the app running ?

I have a similar requirement - Delivery app - suppliers wants continuous bell even if app is closed till action

Please guide me as you have already tried all this
How did you manage this ?

@igorcap
Copy link

igorcap commented May 7, 2020

I was having the same problem. I manage to fix it by doing:

cordova.plugins.backgroundMode.on('activate', function() {
   cordova.plugins.backgroundMode.disableWebViewOptimizations(); 
});

@renznamoc21
Copy link

I was having the same problem. I manage to fix it by doing:

cordova.plugins.backgroundMode.on('activate', function() {
   cordova.plugins.backgroundMode.disableWebViewOptimizations(); 
});

where do you put this event ?

@ragcsalo
Copy link

I have put it like this:

          cordova.plugins.backgroundMode.enable();
          
          setTimeout(function() {
            cordova.plugins.backgroundMode.on('activate', function() {
              console.log('backgroundMode ACTIVE: '+cordova.plugins.backgroundMode.isActive());
              cordova.plugins.backgroundMode.disableWebViewOptimizations();
              setTimeout(function() {
                cordova.plugins.backgroundMode.configure({
                  title: "MyApp",
                  text: "The app is running in the background...",
                  resume: true,
                  hidden: true,
                  bigText: false
                });
              },2000);
            });
            cordova.plugins.backgroundMode.on('deactivate', function() {
              console.log('backgroundMode INACTIVE: '+cordova.plugins.backgroundMode.isActive());
            });
          },1000);

(However, changing the notification parameters doess not work.)

@sirthun
Copy link

sirthun commented Jun 10, 2020

I was having the same problem. I manage to fix it by doing:

cordova.plugins.backgroundMode.on('activate', function() {
   cordova.plugins.backgroundMode.disableWebViewOptimizations(); 
});

I'm try this event ,But the app will be called every time when switching to another app Makes it impossible to use other apps easily

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants