quickstart-android
quickstart-android copied to clipboard
Problem that Firebase Push Notification play first sound in the raw folder for phones above SDK 26
Firebase Push Notification play first a sound at raw for phones above SDK 26.
- raw
- car_park_empty.m4a
- car_park_full.m4a
remoteMessage.notification
{
"sound":"car_park_full",
"android_channel_id":"default_channel_id",
"data":{"carParkStatus":"true"}
}
playing a sound for android 8 and above
soundUri = if (aioNotification.carparkStatus) {
Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + "://"+ context.packageName + "/" + R.raw.car_park_empty_tr);
} else {
Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + "://"+ context.packageName + "/" + R.raw.car_park_full_tr);
}
}
val attributes = AudioAttributes.Builder()
.setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
.setUsage(AudioAttributes.USAGE_NOTIFICATION)
.build()
if (soundUri != null) {
chan.setSound(
soundUri,
attributes
)
}
playing a sound for android 8 and below
var soundUri: Uri? = null
if (aioNotification.carparkStatus != null) {
soundUri = if (aioNotification.carparkStatus) {
Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + "://"+ context.packageName + "/" + R.raw.car_park_empty_tr);
} else {
Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + "://"+ context.packageName + "/" + R.raw.car_park_full_tr);
}
}
if (soundUri != null) {
notificationCompatBuilder.setSound(soundUri)
}
but notification just play first sound in the raw folder.
example -->
- raw
- car_park_full.m4a
play => car_park_full
- raw
- car_park_empty.m4a
- car_park_full.m4a
play => car_park_empty
remoteMessage.notification
{
"sound":"car_park_full",
"android_channel_id":"default_channel_id",
"data":{"carParkStatus":"true"}
}
- raw
- abcde.m4a
- bcdea.m4a
- yery.m4a
Assuming that notification comes this way and that the raw folder is that way.
The sound that plays is abcde.m4a. So It's sound where first index in the raw folder.
Notification was sent from server.
Sound value was sent as 'car_park_full.m4a' from server but Sound value came as 'car_park_full' to client.
Does anyone know what the reason is?
This issue does not seem to follow the issue template. Make sure you provide all the required information.