How do Ionic app running task in the background?

Asked

Viewed 78 times

1

Hello, I am developing an Ionic application (Android and IOS) and this application needs to perform a task in the background every 1 minute even if the application has been closed or the mobile phone restarted. I found some plugins for background tasks, but when I close the application the task is terminated, and I did not find any that start the task automatically when the mobile starts.

Researching on native development I found some Android features that allow to do this: Workmanager, Job Scheduler and Services. But I haven’t found any Ionic plugin that allows me to use these features.

Is there any way to do this with Ionic?

1 answer

0

Task in "background" is one thing, Job is another, Job can be timed as well as can be in "real time". Note that on Android 10 or higher (I do not remember well) if you make much use of it, or a bad use of it, the operating system itself realizes and can reduce the frequency, because the Jobs are very expensive for the device.

Remember, Ionic is Cordova (or Capacitor), being Cordova that will use in the core so there are some plugins around:

And although written in Javascript and not Typescript, it is perfectly functional to access properties in the scope of Window, how is the case of this plugin cited:

window.SchedulerPlugin.configure(...

Can use:

declare var window: any;

Browser other questions tagged

You are not signed in. Login or sign up in order to post.