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

Cannot make notification silent #1858

Closed
nastarfan opened this issue Feb 8, 2021 · 9 comments
Closed

Cannot make notification silent #1858

nastarfan opened this issue Feb 8, 2021 · 9 comments

Comments

@nastarfan
Copy link

Question

Hi, I've been trying to make a notification that doesn't make any sound, but couldn't accomplish it since the library uses channel system on Android.

Ideally I'd like to control the soundName and playSound configuration of the notification through notification configuration object, but apparently on Android it's now bound to the channel configuration. So to have different values for soundName it should be done by providing separate channel for each value.

However, one thing that I can't do is disabling the sound of the notification, even tho I explicitly set the value when creating the channel

PushNotification.createChannel({
    channelId: 'channelidhere', // (required)
    channelName: 'channel name', // (required)
    playSound: false,
    soundName: 'default', // (optional) See `soundName` parameter of `localNotification` function
    importance: 4, // (optional) default: 4. Int value of the Android notification importance
  });
PushNotification.localNotification({
      channelId: 'channelidhere',
      title: 'Test',
      message: 'Test',
      playSound: false,
    });

it seems that the playSound property is disregarded, since the notification would still come with a sound.

The only way that I can disable the sound is by setting the importance to low (2), but this makes the notification heads-up doesn't appear. Is there a way to properly disable the sound while still showing the notification heads-up?

platform: Android
"react-native-push-notification": "^6.1.1",

@Dallas62
Copy link
Collaborator

Dallas62 commented Feb 9, 2021

Hi @nastarfan,
Make sure your channel wasn't already created with a sound by changing the id of the channel (playSound: false).
Channels can't be updated.
Regards,

@eyalyoli
Copy link
Contributor

eyalyoli commented Feb 9, 2021

On android it is easy to control the sound with channel configuration (cannot be overridden by the local notification).

But it is needed for iOS, and I did check this, playSound doesn't work! I browsed the code, it seems that it sets sound = '', but according to Apple's docs on the sound key:

Include this key when you want the system to play a sound ... If the sound file cannot be found, or if you specify default for the value, the system plays the default alert sound.

What I understand is to stop the sound we should remove sound key at all...
What do you think @Dallas62?

@Dallas62
Copy link
Collaborator

Dallas62 commented Feb 9, 2021

@Dallas62 Dallas62 pinned this issue Feb 9, 2021
@nastarfan
Copy link
Author

Hi @nastarfan,
Make sure your channel wasn't already created with a sound by changing the id of the channel (playSound: false).
Channels can't be updated.
Regards,

Yeah I read in the docs about that, I have tried uninstalling and reinstalling the app after making the change i.e. playSound: false, but still can't disable the sound with importance level of 4.

@Dallas62
Copy link
Collaborator

Dallas62 commented Feb 9, 2021

Hi @nastarfan
Can you try with another device ? (reset simulator)
It's possible that the channels preference are stored in the device. Changing the id of the channel is another way to test.

@nastarfan
Copy link
Author

@Dallas62 thanks for your suggestion, I tried changing the id of the channel to a newly created one, it still produces the sound.
Maybe it's overridden by importance value configuration for the channel?

@Dallas62
Copy link
Collaborator

Dallas62 commented Feb 9, 2021

Your are probably using an old version:
https://github.com/zo0r/react-native-push-notification/blob/master/CHANGELOG.md#700-2020-12-23

@nastarfan
Copy link
Author

hi @Dallas62 many thanks for your help! updating to the new version solves the issue. Sorry I didn't notice the change in changelog, that's why I didn't update.

Apparently there's another issue raised by other user, I'll keep this issue opened

@Dallas62
Copy link
Collaborator

Hi @eyalyoli
I published a release to fix your issue.
Regards,

@Dallas62 Dallas62 unpinned this issue Feb 13, 2021
elburu pushed a commit to elburu/react-native-push-notification that referenced this issue Mar 12, 2023
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

3 participants