mobile-messaging-react-native-plugin
mobile-messaging-react-native-plugin copied to clipboard
Sound Not Working for Android, For iOS Working as Expected
Hello
I am facing an issue whereas I am currently passing the soundName and soundEnabled as true for both Android and iOS. On iOS I am receiving the notification sound with the name that I have passed but for Android, it is not working. It is sending the notification with the default sound.
Also, upon checking documentation, it was mentioned to create channel via MobileMessaging.init as below: https://github.com/infobip/mobile-messaging-react-native-plugin/wiki/How-to-create-android-notification-channel-with-custom-sound
But when I tried to do so, it threw me the error that these parameters are not found.
I tested on 2 infobip versions: 12.1.0 13.8.0
Please asssit.
Hello, Android notification channels were introduced in version 13.2.1, but looks like the typescript types were not updated for the new properties in the config. I suppose your errors are typescript ones that property does not exist in type? Assuming I'm right could you ignore the typescript error just to confirm that the custom sound will work?
Thank you for responding. Let me check and get back to you on this.
A few additional details to confirm, if let's say the above works, would we have to reinstall or re-initialize infobip everytime if we want to send different sound notifications or it is just a one time setup?
Secondly, the vibration is working regardless if we send vibration parameter as false or true, can you support in that matter as well?
To add an additional point, if I want to trigger a specific custom sound via API endpoint or Infobip portal, how would I be able to know which channel is Infobip listening to for Android? How will I provide it in the API request with the custom sound details?
@mhudicek any update regarding this?
Hello,
The types for notificationChannel will be added to the typescript types, and also I found the issue why the custom notification channel wasn't being created and the fix is on pull request. These changes will be released in a new version today or maybe on Monday.
We currently only support the ability to create one custom notification channel in the builder, with this in mind yes you would need to re-initialize the SDK if you want to change the sound.
To trigger the custom notification through the API you need to set "soundEnabled": true and "soundName": "custom_sound".
Regarding the vibration parameter. I was testing with an Android device:
| Phone “Sounds and Vibration” setting | Parameters in request body | Sound | Vibration |
|---|---|---|---|
| Sound | — (no parameters) | ✅ | ✅ |
| Sound | "vibrationEnabled": false |
✅ | ❌ |
| Sound | "vibrationEnabled": false, "soundEnabled": false |
❌ | ❌ |
| Sound | "soundEnabled": false |
❌ | ✅ |
| Sound | "vibrationEnabled": true, "soundEnabled": false |
❌ | ✅ |
| Vibrate | — (no parameters) | ❌ | ✅ |
| Vibrate | "vibrationEnabled": false |
❌ | ✅ |
| Vibrate | "vibrationEnabled": false, "soundEnabled": false |
❌ | ❌ |
| Vibrate | "soundEnabled": false |
❌ | ✅ |
| Vibrate | "vibrationEnabled": true, "soundEnabled": false |
❌ | ✅ |
I found that if "Sounds and Vibration" is on "Vibrate" it will vibrate ignoring the vibration we turned off on the notification channel, but I couldn't find the cause for this. Also in this case it won't vibrate when both "soundEnabled" and "vibrationEnabled" are false. But if the phone settings are on "Sound" it will not vibrate.
Hello, new version released 13.8.1 with the fix for Android.
Thank you for responding. I will test and get back to you on this.
Thank you for facilitating in the process. It is working now as expected.
Just a suggestion, for our use case, we have to select different sounds based on the selection by the user in our App. It is working fine on iOS side but for Android, we have to create notification channel id as discussed above and running init instance every time is not ideal. Rather if there could be separate methods to add/create notification channels and clear previous unused channels, that will really help.