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

the task is dying out #467

Open
SokolovRU opened this issue Nov 26, 2022 · 8 comments
Open

the task is dying out #467

SokolovRU opened this issue Nov 26, 2022 · 8 comments

Comments

@SokolovRU
Copy link

maybe I'm testing it incorrectly, but when I launch the application and look at the console, the task works, but when I minimize the application, it stops running within a minute, even less.

@dragorwyin
Copy link

Have same issue, returning to foreground restores task again.

@punov
Copy link

punov commented Jan 3, 2023

Have the same problem,
Android,
"react": "^18.2.0",
"react-native": "^0.70.6",
"react-native-background-timer": "^2.4.1",

Interval stops after 1-2 minutes of running in the background.

@punov
Copy link

punov commented Jan 3, 2023

I was able to fix it by providing more permissions to the Application,

"Apps" > <Select your app> > Remove permissions if app is unused turned OFF
"Apps" > <Select your app> > Battery > Unrestricted 

I can assume it will not suit some of your needs, but if you have to make your app unstoppable, it can save your day.

@chj-damon
Copy link

@punov you mean change those settings on your phone?

@robertsonasc
Copy link

@punov that work for me too, thanks man

@Flobeney
Copy link

Flobeney commented Mar 7, 2023

I have the same problem but for iOS 16.2, and using the following versions :

"react": "18.2.0",
"react-native": "0.71.2",
"react-native-background-timer": "^2.4.1",

On iOS, I can't access those permissions directly, do you know how I can fix that ? Maybe by requesting equivalent permission directly to the user ?
I was thinking about "Background app refresh" but my app doesn't even show up there

@lauhon
Copy link

lauhon commented Aug 9, 2023

Same here (at least on iOs) and the same struggle with react-native-background-actions

To me it seems this is just normal behaviour, 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.

@ocetnik 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

@abakers
Copy link

abakers commented Oct 4, 2023

We solved this on Android by asking the user to turn off the battery optimisation (as this is the issue).

Check if the user has battery optimisation turned on:

const isIgnoring = await BackgroundGeolocation.deviceSettings.isIgnoringBatteryOptimizations();

If isIgnoring is false, ask the user to turn it off (using an alert or modal or whatever you like)

const request = await BackgroundGeolocation.deviceSettings.showIgnoreBatteryOptimizations();

And in the onPress:

BackgroundGeolocation.deviceSettings.show(request)

reference:
https://transistorsoft.github.io/react-native-background-geolocation/interfaces/devicesettings.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants