FCM Custom Sound Not Playing when Receiving Notification

17,016 views
Skip to first unread message

Johnny Thompson

unread,
Jul 21, 2018, 10:35:50 PM7/21/18
to Firebase Google Group
Hello All,

I am building an Android game using Unity and am trying to play a custom sound when the notification has been received by the device, however I can only get the default sound to play. According to the Firebase documentation, to set the sound that is played, you just need to set the sound parameter of the notification to the filename of the sound to be played; the file must be located in /res/raw/. I have tried setting this parameter to the filename with and without the file extension and tried with .mp3 and .wav file types, but the only sound that plays is the default notification sound. I can confirm that in my final .apk file, the sound files that I am trying to play are located in the /res/raw/ folder. Any idea of why I cannot seem to override the default notification sound? Any help is appreciated, thank you!

-Johnny

Stewart Miles

unread,
Jul 23, 2018, 5:11:52 PM7/23/18
to Firebase Google Group
Hi Johnny,


This will only work when the system receives a notification, if the app is in the foreground / background (i.e running) it's up to you to play the sound.

Cheers,
Stewart

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/795b6865-dfdf-4f56-9e27-20c8b12d165b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Johnny Thompson

unread,
Jul 24, 2018, 12:11:07 PM7/24/18
to Firebase Google Group
Hi Stewart,

Thanks for the response. However, the behavior I was attempting to achieve was to have the custom notification sound play while the application is closed or running in the background. Upon further research I learned that as of Android Oreo, the way notifications are handled has changed and you can no longer override the default sound for all notifications on an application. To my understanding, a notification channel needs to be created and then the custom sound can be assigned to that channel. I am still trying to get this to work properly with Unity, but I feel I am heading in the right direction now.

Also note that I did test on a device running an older Android OS and the custom notification sound played as expected with the setup I described in my original post.

Thanks again!
-Johnny
Reply all
Reply to author
Forward
0 new messages