NativeScript / NativeScript/plugins

@nativescript/local-notifications custom sound not working

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

还没有人认领这个 Issue。

主要语言
TypeScript
星标
206
派生
123
平均合并
2 天 1 小时
30 天内合并 PR
1

描述

Hi All, I've been trying to look out for a solution on the internet, and even tried to understand the source code with no avail.

I'm trying to schedule a local notifications as follows

LocalNotifications.schedule([ {
            id: id,
            title: `Some title`,
            sound: 'res://silent.wav',
            ongoing: true,
            notificationLed: false,
            forceShowWhenInForeground: false,
            priority: 0,
            actions: actions,
            icon: 'res://icon',
        } ])

and the notification is displayed correctly. And that's fine. The only problem is that the sound file which I am specifying is not being played, and instead the default android notification sound of the device is playing.

I've even tried using silent.wav and silent as values... I even tried passing <any>null as indicated in the README but nothing worked.

The silent.wav file is located in App_Resources/Android/src/main/res/raw and App_Resources/iOS respectively

Something worth mentioning is that I've been trying this out on Android 11.

Any help and pointers would be greatly appreciated.

贡献指南

打开贡献指南

从这里开始

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

调研方向

从 local-notifications README 和 Android 实现开始,使用报告中的调度调用和 Android 11 作为复现用例。检查如何处理来自 App_Resources/Android/src/main/res/raw/silent.wav 的值;当已调度的通知播放指定的自定义声音而不是设备默认声音时,即表示完成。

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

评估

技术栈
android, typescript
领域
mobile-dev
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
38/100

把新 issue 发到你的邮箱

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