mobile-messaging-react-native-plugin icon indicating copy to clipboard operation
mobile-messaging-react-native-plugin copied to clipboard

Sound Not Working for Android, For iOS Working as Expected

Open msarmady opened this issue 3 months ago • 8 comments

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.

msarmady avatar Aug 27 '25 11:08 msarmady

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?

mhudicek avatar Aug 27 '25 13:08 mhudicek

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?

msarmady avatar Aug 27 '25 13:08 msarmady

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?

msarmady avatar Aug 27 '25 13:08 msarmady

@mhudicek any update regarding this?

msarmady avatar Aug 29 '25 09:08 msarmady

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.

mhudicek avatar Aug 29 '25 12:08 mhudicek

Hello, new version released 13.8.1 with the fix for Android.

mhudicek avatar Sep 01 '25 10:09 mhudicek

Thank you for responding. I will test and get back to you on this.

msarmady avatar Sep 01 '25 10:09 msarmady

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.

msarmady avatar Sep 02 '25 10:09 msarmady