NativeScript / NativeScript/plugins

@nativescript/local-notifications custom sound not working

Open
#259 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
206
Forks
123
Avg merge
2d 1h
Merged PRs (30d)
1

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the local-notifications README and the Android implementation, using the reported schedule call and Android 11 as the reproduction case. Check how the value from App_Resources/Android/src/main/res/raw/silent.wav is handled; done means the scheduled notification plays the specified custom sound instead of the device default.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, typescript
Domain
mobile-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.