Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
MertTutsak opened this issue Oct 25, 2019 · 1 comment

Comments

@MertTutsak
Copy link

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
    3. 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?

@google-oss-bot
Copy link

This issue does not seem to follow the issue template. Make sure you provide all the required information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants