Skip to content

Run things in the background along with the countdown  #70

Description

@GaylordP

Hello and thank you for your library :)

I use react-native-countdown-circle-timer and it works very well. The last five seconds, I execute a "beep" thanks to the react-native-sound library : it works very well too.

But when my application is in the background, the beep does not run.
I tried to do a console.log() and indeed, as soon as the application goes to the background it no longer appears.

I know the stopwatch continues in the background (when I come back, time to spend).

Can you help me run things in the background along with the countdown ? Thanks you very much

Sound.setCategory('Playback')
const soundWait = new Sound('wait.mp3', Sound.MAIN_BUNDLE)

let lastShowTimerText
const remainingAlreadyShowed = []

<CountdownCircleTimer
  isPlaying
  duration={60}
  colors="red"
  size={120}
  trailColor="#fff"
>
  {({ remainingTime }) => {
    console.log(remainingTime) // not showed in background, but the timer continued well when I come back 

    if (undefined === remainingAlreadyShowed.find(item => item === remainingTime)) {
      remainingAlreadyShowed.push(remainingTime)

      if (remainingTime <= 5) {
        soundWait.play()
      }

      lastShowTimerText = <Animated.Text style={styles.timer}>{remainingTime }</Animated.Text>

      return lastShowTimerText
    } else {
      return lastShowTimerText
    }
  }}
</CountdownCircleTimer>

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is neededmobileReact Native

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions