'cordova.plugins.backgroundMode.onactivate is not a function' in Ionic 3 app
See original GitHub issueI did a fresh install of this plugin using the Ionic V3 instructions (https://ionicframework.com/docs/v3/native/background-mode/). When I try to run the app in the simulator or device I get TypeError: cordova.plugins.backgroundMode.onactivate is not a function. (In 'cordova.plugins.backgroundMode.onactivate()', 'cordova.plugins.backgroundMode.onactivate' is undefined
when I try to put the app in the background. It sees the subscription to the enable correctly. Any suggestions as to what is going wrong? I’ve the necessary import to app.module.ts.
Here is the code that is in the app.component.ts
import { BackgroundMode } from '@ionic-native/background-mode';
....
constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen, backgroundMode: BackgroundMode) {
platform.ready().then(() => {
// Okay, so the platform is ready and our plugins are available.
// Here you can do any higher level native things you might need.
statusBar.styleDefault();
splashScreen.hide();
backgroundMode.enable();
backgroundMode.on('enable').subscribe(() => {
console.log('enabled')
})
backgroundMode.on('activate').subscribe(() => {
console.log('activated')
})
});
}
Issue Analytics
- State:
- Created 5 years ago
- Reactions:3
- Comments:27 (2 by maintainers)
Top Results From Across the Web
cordova.plugins.backgroundMode.onactivate is not a function
For someone looking for the answer, like i do, with this code i could make it work using ionic v4: cordova.plugins.backgroundMode.enable(); ...
Read more >Angularjs – Run ionic app in a background mode - iTecNote
I've recently implemented a feature like this in my project. I did use Ionic and I did use the Cordova plugin background mode...
Read more >Location detection and HTTP call on background mode using ...
I have an ionic app in which the app behaves in the following way when it is in the foreground. ... function ()...
Read more >cordova-plugin-background-mode-xjp - npm
Prevent apps from going to sleep in background.. Latest version: 0.7.3, last published: 2 years ago.
Read more >Background Mode - Ionic Native
Cordova plugin to prevent the app from going to sleep while in background. Requires Cordova plugin: ... Checks if background mode is enabled...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thats the problem: using a forked version is always the solution
Hi @rastographics
Maybe:
@n1705771 How did you solved ‘cordova.plugins.backgroundMode.onactivate is not a function’ ?
I installed
https://github.com/lkonzen-garupa/cordova-plugin-background-mode
and add the code for wake_lock
Is working for android 5, 7 and 10 😃