Steps to reproduce:
1. Use the code below in your app.js:
var channel = Ti.Android.NotificationManager.createNotificationChannel({
id: 'my_channel',
name: 'TEST CHANNEL',
importance: Ti.Android.IMPORTANCE_DEFAULT
}),
notification = Titanium.Android.createNotification({
contentTitle: 'Notification 2',
contentText : 'Just another notification',
contentIntent: Ti.Android.createPendingIntent({intent: Ti.Android.createIntent({})}),
icon: Ti.App.Android.R.drawable.warn,
number: 5,
when: new Date().getTime(),
// Sound file located at /platform/android/res/raw/test.wav
sound: Ti.Filesystem.getResRawDirectory() + 'test.wav',
});
setInterval(function(){
Ti.Android.NotificationManager.notify(100, notification);
}, 5000);
2. Build for android device/emulator.
3. After the app launch you will get a local notification with custom sound every 5 seconds.
Actual results:
1. On Android 7.0 & older the custom sound works fine.
2. On Android 8.0+ the custom sound does not play but the default system notification sound plays.
Expected results:
1. Custom sounds should play consistently on all Android versions.
This looks like an undocumented breaking-change on Google's end. I believe you're supposed to assign the custom sound to the notification channel now via the Java
NotificaitonChannel.setSound()
method and the sound assigned to individual notifications are now ignored. [NotificationChannel.setSound()](https://developer.android.com/reference/android/app/NotificationChannel.html#setSound(android.net.Uri,%20android.media.AudioAttributes)) The problem with assigning the sound to the notification channel is that you can't change the sound file unless you delete and recreate the channel. Hmm...Yeah, the Java
Notification.Builder.setSound()
method is definitely deprecated as can be seen here... [Notification.Builder.setSound()](https://developer.android.com/reference/android/app/Notification.Builder.html#setSound(android.net.Uri)) Unfortunately, it wasn't documented as deprecated on the Google support library side that we were using here... [NotificationCompat.Builder.setSound()](https://developer.android.com/reference/android/support/v4/app/NotificationCompat.Builder.html#setsound)Unfortunately, this issue cannot be *+fixed+*. The solution is to provide a new feature where you can assign a "sound" to
NotificationChannel
. This will be implemented via: [TIMOB-26484]