Best practice for long time background operation

In my app users have an option to download all necessary data from the server to work offline. But this process can take a lot time - up to 10 minutes with good internet connection. Of course, users don’t want to look on downloading screen for a long time, and they turn off screen, or switch to another app. After that action my app is running in the background but unexpectedly stops running some time later.

I tried to use BackgroundTask.beforeExit, but it didn’t work. I couldn’t understand why, and I spent a lot of time to try getting it work. And I was very badly surprised when I found in the capacitor sources next lines:

// No-op for now as Android has less strict requirements for background tasks

This method do nothing!

So… Is there any good practices to handle such situation on android?

1 Like

Hi @to2n , did you find any solution for this background-task problem?

Not yet. And it looks like there isn’t “legal” solution for iOS due to platform restrictions. Or maybe I misunderstood something.

@to2n Did you have any luck since April, with finding a solution to your problem?