firebase / firebase/quickstart-android

Problem that Firebase Push Notification play first sound in the raw folder for phones above SDK 26

Open
#981 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Kotlin
Stars
9.3k
Forks
7.4k
Avg merge
2d 19h
Merged PRs (30d)
8

Description

Firebase Push Notification play first a sound at raw for phones above SDK 26.

- raw
1. car_park_empty.m4a
2. 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
1. car_park_full.m4a

play => car_park_full

- raw
1. car_park_empty.m4a
2. car_park_full.m4a

play => car_park_empty

----
remoteMessage.notification

{
"sound":"car_park_full",
"android_channel_id":"default_channel_id",
"data":{"carParkStatus":"true"}
}

- raw
1. abcde.m4a
2. bcdea.m4a
2. 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?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.