react-native-background-timer icon indicating copy to clipboard operation
react-native-background-timer copied to clipboard

Not working for background after 3 minutes

Open beshoo opened this issue 6 years ago • 5 comments

I search all posts, no one provides any solutions. I am targeting android system, I want to refresh a webview in the background each one min, Well after passing 180 sec. the app stop.

I am following the normal example provided on the home page of this plugin.

So what is the deal here?

beshoo avatar Apr 26 '19 12:04 beshoo

Hi @beshoo I found the problem:

The tasks cannot be scheduled any more frequently than every 15 minutes, in this case is blocked 3 minutes.

The exact timings of task execution are unpredictable, as both Android and iOS use black-box algorithms, which depend on factors like device sleep state.

For more information see here:

https://github.com/transistorsoft/react-native-background-fetch

skantus avatar Jun 29 '19 12:06 skantus

I find a solution in internet but it's not really great...

const monitorProgress = async (dispatch, id) => {
    if (pos >= duration * AUDIO_DONE_AT) {
      BackgroundTimer.stopBackgroundTimer();
      dispatch(addAudioDone(id));
    }
};

const startMonitoring = (dispatch, id) => {
  BackgroundTimer.runBackgroundTimer(() => {
    monitorProgress(dispatch, id);
  }, MONITOR_INTERVAL);
};

reload... the timer every 3minutes

yelkamel avatar Oct 08 '19 17:10 yelkamel

@yelkamel hi friend, any better solution here of the 3 min limitation?

Symous avatar Nov 07 '19 09:11 Symous

I am facing the same problem

mjm918 avatar Nov 07 '19 11:11 mjm918

I need to send the current location of the device every minute but I'm having a problem when the device is locked. First I created a timer that runs every 10 seconds (just for testing purposes ) when the app is open or in the background works perfectly fine, but if I lock the device, the timer takes more than 10 seconds to run. These are some test that I did that measure how often is running (in seconds): [ 10, 9, 9, 9, 10, 9, 10, 9, 10, 10, 9, 10, 41, 89, 44, 76, 55 ] As you can see, it's running every 10 seconds because the app is open or in the background but as soon as I locked the phone the time to run increases. I did another test, this time setting the timer to one minute and these are the results: [ 60, 60, 164, 219, 395, 326 ] As you can see, it takes more than 5 minutes to run when it suppose to be running every minute.

HugoLiconV avatar Jan 09 '20 19:01 HugoLiconV