0

I got Uncaught TypeError: cordova.plugins.backgroundMode.onactivate is not a function when i try to run my application on background.

I’m unable to solve the issue can anyone help me with this thanks

I tried uninstall and install the plugin

this.platform.ready().then(() => {
   this.backgroundMode.enable();
   this.backgroundMode.on(‘activate’).subscribe(() => {
    // logic
    });
 });

Uncaught TypeError: cordova.plugins.backgroundMode.onactivate is not a function

1 Answers1

1

For someone looking for the answer, like i do, with this code i could make it work using ionic v4:

cordova.plugins.backgroundMode.enable();
cordova.plugins.backgroundMode.overrideBackButton();
cordova.plugins.backgroundMode.on('activate', function () {
    console.log('ACTIVATE ON background mode');
}

You need to add this at the beginning of the ts file:

declare var cordova: any;

I found better help on this fork: https://github.com/fyayc-chrisat/cordova-plugin-background-mode

user3486626
  • 139
  • 1
  • 6