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

未关闭
#981 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
25/100
Issue 类型
缺陷
描述清晰度
需要澄清
活跃度
停滞
技术栈
android, firebase, kotlin
领域
mobile

调研方向

未指定仓库文件或测试。请从 remoteMessage.notification payload 开始,将使用 chan.setSound 的 Android 8+ 通知渠道路径与使用 setSound 的较旧通知构建器路径进行比较。使用列出的 raw sounds 重现,并验证在每个 Android 版本上播放的是服务器请求的 sound,而不是第一个 raw 资源。

由索引模型根据 Issue 内容生成。

描述

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?

主要语言
Kotlin
星标
9.3k
派生
7.4k
平均合并
7 天 9 小时
30 天内合并 PR
6

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

firebase/quickstart-android 的其他 Issue

查看 firebase/quickstart-android 的全部 Issue

相似的 Issue

更多 Kotlin Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。