GeoTecINIT / nativescript-task-dispatcher

NativeScript-based mobile background task scheduler and dispatcher
Apache License 2.0
18 stars 6 forks source link

(Question) Run task while app is closed #64

Closed Peasplayer closed 1 year ago

Peasplayer commented 1 year ago

Hi, I wanted to ask if it's possible that a task continuos to run while the app has already been closed. Thanks

agonper commented 1 year ago

Hello @Peasplayer, thank you for your interest. All the tasks dispatched by the plugin run by default in the background, therefore, they run whether the app is open or closed.

From your comment do I understand that you'll want to run a task longer than the default maximum execution timeout (3 minutes)? If so, our approach with this library is to split the task into steps, so we can schedule the task repeatedly and resume the execution from the last checkpoint. We do this because a background service is not guaranteed to run endlessly in Android without being killed by the OS at some point.

Nevertheless, could be good to know about your use case, so we can better help.

Peasplayer commented 1 year ago

Hi, my mistake was that I tried to access a variable that was set while the app was active. That caused an exception which stopped the task and didn't show the desired result. Thank you for you quick response!

agonper commented 1 year ago

Glad that you could fix the issue @Peasplayer! Thanks for the update