We have created notification channels for devices running on Oreo and above, that use a custom notification sound that is located in our /res/raw
folder. Recent
It seems like this issue setting the soundUri
as follows:
val soundUri = Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + "://" +
context.applicationContext.packageName + "/" + R.raw.notification)
It looks like the value of R.raw.notification
changed from 2131689979
(version where sound works) to 2131755515
(version where sound doesn't work). And since you can't change your notification sound with Notification Channels, I am almost certain that the channel is trying to resolve the soundUri
with the old resource id (android.resource://our.package.name/2131689979
).
I think the better approach is to reference the file directly by name as follows:
val soundUri = Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + "://" +
context.applicationContext.packageName + "/raw/notification")
I also notice apps like Facebook Messenger and Slack use a public Notifications folder where they probably just copy the file over and reference that exact path. This also seems to allow the user to re-select the app-provided sound because it is visible in the filesystem.