Custom Sound does not work depending model device or the version of Android
See original GitHub issueBug
I have the following problem: On a given device, the customized sound and vibrate works normally, and on another device only the standard sound works and no vibrate never.
Environment info
Device custom sound and vibrate ok: Vernee Mars pro Android 7.0 Device custom sound dont play (play default) and vibrate not work: Xiaomi Mi A2 Lite Android 10. Using PushNotification.checkPermissions on 2 devices I get: { alert: true }, nothing appears about badge or sound.
System: OS: Windows 10 10.0.18362 CPU: (4) x64 Intel® Core™ i5-4570 CPU @ 3.20GHz Memory: 5.39 GB / 15.88 GB Binaries: Node: 12.18.3 - C:\Program Files\nodejs\node.EXE Yarn: 1.13.0 - C:\Program Files (x86)\Yarn\bin\yarn.CMD npm: 6.14.6 - C:\Program Files\nodejs\npm.CMD Watchman: Not Found SDKs: Android SDK: API Levels: 23, 27, 28, 29 Build Tools: 23.0.1, 27.0.3, 28.0.3, 29.0.2, 30.0.2 System Images: android-27 | Google APIs Intel x86 Atom, android-28 | Google APIs Intel x86 Atom Android NDK: Not Found Windows SDK: Not Found IDEs: Android Studio: Version 4.0.0.0 AI-193.6911.18.40.6626763 Visual Studio: Not Found Languages: Java: 1.8.0_201 Python: 2.7.15 npmPackages: @react-native-community/cli: Not Found react: 16.13.1 => 16.13.1 react-native: 0.63.3 => 0.63.3 react-native-windows: Not Found npmGlobalPackages: react-native: Not Found
Library version: x.x.x react-native-push-notification": “^6.1.1”,
Reproducible sample code
PushNotification.channelExists('channel-push-rotina', (exists) => {
if (!exists) {
PushNotification.createChannel({
channelId: 'channel-1489', // (required)
channelName: 'PushChanel', // (required)
vibrate: true,
// soundName: 'alertsound2', // (optional) See `soundName` parameter of `localNotification` function
});
}
});
function sendNotification() {
PushNotification.localNotification({
title: '14:00 - TITLE HERE',
channelId: 'channel-push-rotina',
message: 'You pushbutton ou push the nn button!',
smallIcon: 'ic_notification',
largeIcon: 'ic_launcher',
soundName: 'alertsound2',
playSound: true,
vibrate: true,
vibration: 1000,
autoCancel: false,
actions: ['close'],
});
}
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:8
Top GitHub Comments
sorry for my english, i speak english as well as i’m a programmer 😃
Sorry the code I sent didn’t really match what I had, I probably had already tried so much that when posting my example I was wrong to post with the commented line.
So … you’re right, after switching libs when trying to build, I got other errors that the original lib didn’t occur, so I went back, and decided to do more tests, and realized that for my project I really needed to create 2 channels, 1 with the default sound and one with the custom sound, and there it worked beautifully.
Sorry for taking your time. Below the code that worked for me.
Nice to see it works !
This is probably because the sound was not set the first time the code run, then the channel wasn’t updated.
It would take me too much time for now, but there is some improvement needed in the documentation. Too much important information… 😄