How to Run Ionic in the Background

Run function when background mode is active using ionic 4

Better to do it as in example below:

this.backgroundMode.on('activate').subscribe(s => {
console.log('backgroundMode activate');
});
this.backgroundMode.enable();

More information about it you can take from this
Cordova Background Plugin

Background mode is not working in ionic 5

Check your project type in ionic.config.json file.

If the type is "ionic-angular", then install 4.x.x version.

npm i -s @ionic-native/background-mode@4.20.0
If the type is "angular", then install 5.x.x-beta version

npm i -s @ionic-native/background-mode@5.0.0-beta.24

Credit goes to - Diego Desenvolvedor for this link here

How do create background service for Android in Ionic?

Your question is composed of several questions.

Runing after restart

There is an Ionic plugin that can do this. Autostart

Send request when application is closed

You can use the Backgroud mode Ionic plugin.

Display notification

OneSignal can display notifications, sent from your backend, on your smartphone. There is also a Ionic plugin for OneSignal. The plugin will take care of being active even if your app is not and will also always be up, even after restart.



Related Topics



Leave a reply



Submit