OneSignal-Android-SDK icon indicating copy to clipboard operation
OneSignal-Android-SDK copied to clipboard

[Bug]: Channel with custom sound fails to play sound after rebuild / update

Open armiiller opened this issue 1 year ago • 1 comments

What happened?

When trying to deploy an app update (aka rebuilding and distributing), sending notifications to a channel with a custom sound no longer play the sound. I still receive a vibration, and push notification, just the sound is not played.

This is a result of the sound Uri being built using the resources id. When doing a grade rebuild, ids will change. Thus the channel is trying to play a resource that no longer exists.

https://github.com/OneSignal/OneSignal-Android-SDK/blob/821bf86aa849c4b69ac203c86041eaf5837e80b9/OneSignalSDK/onesignal/notifications/src/main/java/com/onesignal/notifications/internal/common/NotificationHelper.kt#L196

Other similar projects have dealt with similar issues with fixes.

Steps to reproduce?

1. Build your app. Install. Run the app to create the notification channels. Send at least on push notification to the channel.
2. Build a new version, with added sound files (as to cause gradle to rebuild and remap resources). Make sure to update your version code. Install on phone that had previous version installed. Send push notification to same channel. Custom sound will not play.

What did you expect to happen?

I expected the custom channel sound to play when a push notification is received (because we are technically passing a string) and app updates/rebuilds should not cause failures.

OneSignal Android SDK version

Release 4.8.10

Android version

14

Specific Android models

Should affect all models. And all versions. It's very clear in the code that a resource path using build ids will fail.

Relevant log output


Code of Conduct

  • [x] I agree to follow this project's Code of Conduct

armiiller avatar Jan 22 '25 21:01 armiiller

Other similar issues that give this bug more clarity:

  • https://github.com/invertase/react-native-notifee/issues/341
  • https://github.com/invertase/notifee/pull/98/files

armiiller avatar Oct 28 '25 12:10 armiiller