Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOs Background Action stalls after background time #191

Open
lauhon opened this issue Aug 9, 2023 · 4 comments
Open

iOs Background Action stalls after background time #191

lauhon opened this issue Aug 9, 2023 · 4 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@lauhon
Copy link

lauhon commented Aug 9, 2023

To me it seems this is just normal behavior since the ios part relies on beginBackgroundTaskWithname. As it states there the background tasks have an assigned time which they get to run, after that time the process is stalled.

@Rapsssito Would it be possible to use "normal" Background Tasks in iOs to prevent the process to be stopped so soon?

Im willing to contribute to make this happen, I just don't know if Background Tasks will perform as desired

(The same topic applies to react-native-background-timer)

@Rapsssito
Copy link
Owner

Rapsssito commented Sep 7, 2023

Hi @lauhon, you are more than welcome to send a PR! However, take a look at this comment here: https://stackoverflow.com/questions/58960411/how-to-get-your-ios-app-to-run-in-the-background-for-longer-than-3-minutes

We haven’t had the old 10 minute window for years so that is simply no longer applicable. That was reduced to 3 minutes in OS 7, and further reduced to 30 seconds in iOS 13. (There is a new concept of background tasks, for running tasks longer than 30 seconds, but the the OS will run these at its own discretion, e.g. at night, when the user is charging their device, so that’s not really applicable here).

@Rapsssito Rapsssito added bug Something isn't working enhancement New feature or request and removed bug Something isn't working labels Sep 7, 2023
@lauhon
Copy link
Author

lauhon commented Sep 13, 2023

Nice to know. I will look into it as soon as I can.

Hopefully, the behavior of background tasks ends up making sense. I guess if it's not 100% intuitive I can add a setting/flag to control if the task should run as it's possible already, or with the background task API.

@Rapsssito Rapsssito added the help wanted Extra attention is needed label Oct 11, 2023
@contactsimonwilson
Copy link

FWIW, I have an app using this library on iOS that successfully stays in the background for 2+ hours. That being said, I'm also doing background audio and location. For me, the key to getting background execution to run longer was ensuring that the app's memory and cpu usage in the background was low.

@akinlekan28
Copy link

FWIW, I have an app using this library on iOS that successfully stays in the background for 2+ hours. That being said, I'm also doing background audio and location. For me, the key to getting background execution to run longer was ensuring that the app's memory and cpu usage in the background was low.

@contactsimonwilson can you share a snippet or gist on how you were able to implement this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants