Firebase Cloud Messaging custom sound


#1

Hey !

I am implementing an app that uses notifications with the help of Firebase Native and I’m having a hard time placing my custom sound file in the app. Does anybody know where to place it ? I have tried pretty much everywhere with no success.

Thank you !


#2

In android, you should place your file in /platforms/android/res/raw/custom_sound.mp3 and set notification`s sound property value with custom_sound.mp3 like below.

notification: {
          title: 'abc',
          body: 'aaaaaa',
          sound: 'custom_sound.mp3'
        }

In ios, Add files to Resources directory within the Xcode project in /platforms/ios/project-name.xcodeproj.
For more detail specification, You can refer to https://documentation.onesignal.com/v3.0/docs/customize-notification-sounds.


#3

any one get success on FCM custom sound effect?


#4

put this line in config.xml

<resource-file src="src/assets/sound/sound.mp3" target="app/src/main/res/raw/sound.mp3" />


#5

Hi, i have problem with playing custom sound in ios,
what i did are set

    const options: PushOptions = {
     android: {
       sound: 'true',
       vibrate: 'true'
     },
       ios: {
           alert: 'true',
           badge: true,
           sound: 'true'
       }
    };

then

        registration_ids : this.tokenList,
        notification:{
           title: "title",
           body: "body",
           sound: "sound"
        },
        data: {
          somethiing:""
        }

in config.xml
<resource-file src="src/assets/sound/sound.wav" target="sound.wav" />

but it only plays the default sound, do u hv any idea why