expo/react-native: How to play a scheduled sound while app in the background (Alarm App)

Viewed 84

For context: I'm developing an alarm app, which needs to play a sound at a certain time, even when the app is not running/not in the foreground. Preferably, it should wake up the screen and open the alarm page where the user can shut it off (but at this point I'd be happy if it rings or does anything at all)

The issue: Expo/React Native stops all activities by default once it's not running in the foreground anymore

What I tried (a lot, but here are the 'solutions' where I felt, it's closest to the answer):

This is the code that should be running in the background (at the time of the alarm, the first code leads to another page where the second code runs on render):

// Alarm page

setTimeout(function activateAlarm() {
        navigation.push('AlarmRings');
      }, ringsInMilliseconds);
// AlarmRings page

  useEffect(() => {
    playSound();
  }, []);

and here's a link to a small version of my project to replicate the issue: https://github.com/janaabf/wakeup-buddy

I appreciate ANY help, I've been stuck on this for way too long and ejecting expo is not an option.

0 Answers
Related