jamesisaac / react-native-background-task

Periodic background tasks for React Native apps, cross-platform (iOS and Android), which run even when the app is closed.
MIT License
1.11k stars 110 forks source link

no timers in background task #48

Open vitto-moz opened 6 years ago

vitto-moz commented 6 years ago

I think this info should be in the documentation if you define task with a setTimeont - callback will be called only after app comeback to foreground mode


export const define = function (dispatch) {
  BackgroundTask.define(() => {
    dispatch(devicesDetailsActions.startUpdatingCycleBackground())
    setTimeout(() => {
      console.log('BackgroundTask timeout') // <===THIS WILL BE RUN IN FOREGROUND
    }, 3000)
  })
}
jussirantala commented 6 years ago

On iOS or Android?

vitto-moz commented 6 years ago

@jussirantala Andoird, haven't tested on iOS yet?

jnurkka commented 5 years ago

@vitto-moz how did you work around this issue? Because iOS will kill the app if the background task runs for longer than 30sec, I'm trying to use a timeout to stop the task if the asynchronous call has not yet finished after just below 30sec