How to let audio play when the iOS device is in Silent mode?

By default, audio only plays if the iOS device is unmuted (mute side switcher on iOS devices).

In order for audio to work by default, the app must declare that audio playback as a core feature of the app, and thus it should not be muted in “Silent Mode”.

This can be done by configuring the playback as audio session category.

You can choose from several audio session categories and settings to customize your app's audio behavior.

These categories translate to the categories in Apple's official documentation.

Bellow an example how to configure the audio session category to change the default behavior:

useFocusEffect(
  useCallback(() => {
    // iOS audio session category must be set to `playback` first, otherwise playback
    // will have no audio when the device is silenced.
    //
    // Usually it's desireable to set the audio's category only once during your app's main component
    // initialization. This way you can guarantee that your app's audio category is properly
    // configured throughout the whole lifecycle of the application.
    AudioSession.setCategory('playback').catch((error) => {
      // Handle any native errors that might occur while setting the audio's category.
      console.log(
        "Failed to set app's audio category to `playback`:\n",
        error
      );
    });
  }, [])
)