Push Notification: Include custom sound files in build
complete
C
Carson Wah
Currently, sound can only be
'default' | null
. But as far as I researched, there are ways to use custom sound files in build as the notification sound.Suggestion: Sound files (preprocessed for the format requirements) can be all put in a folder, then specify the folder path in
app.json
. Expo should be responsible for bundling them into the app. And once the files are bundled, we can use sound: 'default' | null | 'filename.xxx'
to customize the sound when sending notification.Use case: This can be really useful in some scenarios such as playing a long alert for a merchant, to notify him that there is an new order.
Related links:
iOS:
- https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/SupportingNotificationsinYourApp.html#//apple_ref/doc/uid/TP40008194-CH4-SW10
- https://stackoverflow.com/questions/37536591/change-push-notification-sound
- https://medium.com/@prakashmaharjan20/play-custom-push-notification-sound-ios-a767748a46
Android:
Brent Vatne
complete
this is possible now as of sdk 42! see the notification api docs for more information. also, please note that this will only work on apps built with EAS Build due to limitations of the classic build system (more about that in this two-part blog post).
tamir hizmi
Still does not work... Brent Vatne can you please explain more how can we enable this feature?
Brent Vatne
tamir hizmi
Brent Vatne: This is working for local notification, but for push notification using expo servers this feature is still not supported
Josh Guthrie
I see this is marked as complete, but it's not clear to me how to set a custom notification sound for push notifications sent via the Expo servers. I can trigger local notifications with custom sounds just fine, but, if the app is backgrounded on iOS, I cannot figure out the right way to specify custom sounds for the notification.
Chris Finn
It is still not possible to trigger custom sounds remotely on iOS because the SDK clients and the Expo push notification server do not allow a custom string for the sound property.
Brent Vatne
complete
this is possible now as of sdk 42! see the notification api docs for more information. also, please note that this will only work on apps built with EAS Build due to limitations of the classic build system (more about that in this two-part blog post).
B
Brett
This feature would be awesome in the managed workflow! I'm scared to eject.
andy sandy
Even for bare work flow , where I can include the path
Kurt Matthew San Miguel
Adel Alawdy dasari santhosh
I saw this forum of expo, and they seem to make it work:
Basically, it only works in Expo Bare Workflow. We need to expo eject to make this work.
Kurt Matthew San Miguel
I tried it and it definitely works
Adel Alawdy
I have copy-paste the example of playing a custom sound and put the .wav file in the assets folder, but still, I've got the notification without playing the specified sound.
They did not mention anything about putting the sound in a specific folder ??
Am I right!
If anyone could help, I will be thankful.
dasari santhosh
How to include the sound file for Manage expo Project
Kurt Matthew San Miguel
dasari santhosh: I have an "alert.wav" file which I want to play for the notifications. I placed it on the root folder of my project, then I set the sound: "alert.wav" in scheduleNotificationAsync.content.
For example:
await Notifications.scheduleNotificationAsync({
content: {
title: "My Title",
body: "My Message",
sound: "alert.wav"
},
trigger: {
seconds: 1,
channelId: "my_channel"
},
});
The notification initiates but it does not play the alert.wav
How do we solve this problem?
dasari santhosh
Kurt Matthew San Miguel:
I have also same question , they haven't mentioned any where, where to place the sound file ?
Kurt Matthew San Miguel
dasari santhosh: I see, okay I'll try. Will reply here if I got the solution.
dasari santhosh
Kurt Matthew San Miguel: Hey Thank you so much
Aymen Guidad
dasari santhosh: this is work for bare workflow only.
B
Benjamin Müller
This is a very important feature. For every app that sends an alert ist is an absolute show stopper!
Load More
→