Playing a custom sound for local notificaitons

Hi,

I’m trying to get a custom notification sound to work.
It looks like I should be able to set the sound to a string here:

At the moment only the default sound plays, I would like to get a custom wav playing.
Setting the sound to a string has no effect. What should I do?
Hope you can help!!

(this is on iOS/SDK version 39)

Daniel

custom notification sounds are currently bare workflow only, so you’ll have to expo eject before using that feature

This is because the files need to be in a particular location (on Android- in the res/raw sources, and on iOS- in the iOS application bundle), which you only have access to adding files to in the bare workflow

Thanks for your quick response - so eject, then add the sound file (say “alarm.wav” to the bundle in XCode), and refer to by simple filename in the js?

that’s correct, it should look like this:

on android, you should place it in: android/app/src/main/res/raw/

then in your JS code you’d just reference it as notification.wav

1 Like

Hey, I just tried this (see alarm.wav in XCode) but wasn’t able to get the sound to work.

I’m at the moment in development mode using the simulator.
Do I need to create a production binary build?

const _notificationID = await Notifications.scheduleNotificationAsync({
        content: {
          title: "One Alarm",
          subtitle: "It's time.",
          sound: "alarm.wav",
        },
          trigger:null
      });

Daniel

no it works on a development build for me as well, you may want to run your app through the debugger to see what’s going on

Thanks, I did a git reset --hard, ejected again, went through the steps this time it worked! I must have bungled something the first time. Thank you so much :slight_smile:

1 Like

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.