invertase / react-native-notifee

Moved to https://github.com/invertase/notifee
https://invertase.io/blog/open-sourcing-notifee
Other
466 stars 31 forks source link

[Android] How can you set a dynamic custom sound per notification? #354

Closed meenie closed 3 years ago

meenie commented 3 years ago

Greetings,

I'm wanting to let my customers pick which sound they want to use for a particular push notification. I noticed that you have to set the sound option on the group that needs to be created for notifications to even work. But it seems I'm not able to override the sound within the android.sound property you use in notifee.displayNotification(). Is this even possible? Or am I going to have to create a different notification channel for each one of my different sounds?

mikehardy commented 3 years ago

You may have hit on an issue we have right now with android custom sounds needing to be specified without the extension, based on the last part of your comment: https://github.com/notifee/react-native-notifee/issues/350

But to the first part of your question: If I understand correctly, you set the sound on a notification channel, and after channel creation you may not programmatically alter the sound - it is under user control at that point.

If you wanted to allow the user to set the sound for their notifications I believe you would have to dynamically create a notification channel in response to the user selecting a sound, then remember that notification channel id for later use - which is a bit cumbersome but could work? This is just the way the Android system works, as I understand it - it's not a Notifee thing other than Notifee exposing the system APIs for use

meenie commented 3 years ago

I was just about to come back and close this because it's not possible what I'm trying to do. Although your idea of dynamically creating one...I'm not sure it's worth the time to spend on doing that haha. Nor would an Android user be happy with this type of approach because it would essentially disallow them to set their own custom sound like they are used to.

As for your first statement, I did see that and I did manage to get it all working after I updated my channel id from the old one. Thanks!