DEV Community

Alberto Peral
Alberto Peral

Posted on

How to persist countdown in background react native expo

I've tried use a countdown in background in react native expo, i use webview:

<WebView
        onMessage={() => {

            if (props.initialHour >= finishHour) {
                props.setMinutes(null);
                props.stopSound();
            }
        }}
        source={{
            html: `<script>
          setInterval(()=>{window.ReactNativeWebView.postMessage("");}, ${props.interval})
          </script>`,
        }}
    />
Enter fullscreen mode Exit fullscreen mode

but only persist interval 5min in background and i've tried setTimeout too and the same results.

How can i do it? without using expo eject

Please help me :( and thank you!

Top comments (0)