How to use cordova plugin BackgroundMode in Ionic 2 with TypeScript?

I just added it with ionic plugin add cordova-plugin-background-mode

In the code I then add this after the imports:

declare var cordova:any;

and use this:

platform.ready().then(
    () => {
        console.log("MyApp::constructor platform.ready");
        cordova.plugins.backgroundMode.setDefaults({ 
            title: 'My App Name', 
            text: 'Active in background...');
        cordova.plugins.backgroundMode.enable();
    }
);
1 Like