1

I'm trying to send clevertap push notification with custom sound. I have added the sound files to the path "/Users/Per/ProjectNa/android/app/src/main/res" of react native android project. Notification with default sound is working but trying to the send the notification with custom sound (eg:alarm_sound.mp3) is not playing the sound. I'm receiving the notification without sound. Not sure what is happening. Please let me know where I am going wrong.

File Names Eg: alarm_sound.mp3, tower_clock_sound.mp3

DDM
  • 113
  • 1
  • 17

1 Answers1

2

The CleverTap SDK looks for the sound file in the raw folder in your app and not the res folder. Please take a look at this documentation where it is explained on how to add sound files to your app so that they can be used for push notifications.

If you want custom sounds to work for Android Oreo and above then create a notification channel to which you will be sending the push notifications in the following manner in your JS file -

CleverTap.createNotificationChannelWithSound('YourChannelId','YourChannelName','YourChannelDescription',3,true,'name_of_sound_file.mp3');

Please make sure the sound file is present in the raw folder of your app according to the documentation link provided above.

Darshan Pania
  • 1,374
  • 13
  • 20
  • even after putting the files in raw folder the custom sounds are not playing once notification is received. Pls help me where i'm going wrong – DDM Sep 17 '18 at 09:24
  • @DDM Which Android version are you targetting? – Darshan Pania Sep 17 '18 at 10:07
  • android version 6.0 – DDM Sep 17 '18 at 10:55
  • And what is the version of the CleverTap React-Native SDK you are using? – Darshan Pania Sep 17 '18 at 11:25
  • "com.clevertap.android:clevertap-android-sdk:3.1.1" – DDM Sep 17 '18 at 12:02
  • 1
    Ah! The custom sound feature was added with CleverTap Android SDK v3.1.4 I would suggest you update the CleverTap React-Native SDK to the latest version v0.2.3 (https://www.npmjs.com/package/clevertap-react-native) which has the latest CleverTap Android SDK which supports the custom sound feature in Push Notifications. – Darshan Pania Sep 17 '18 at 12:22
  • You're welcome! It would be of great help to others with similar queries if you mark my answer as the correct answer. :) – Darshan Pania Sep 18 '18 at 06:22
  • In android versions 5 to 8.0 its working as expected, but custom sound is not working in 4.4.4. Clevertap version:"'com.clevertap.android:clevertap-android-sdk:3.1.10'". Please let me kno is there any change to be done for kitkat versions. – DDM Sep 19 '18 at 07:19
  • There should be no changes for Kitkat, can you try on any other 4.4.4 device? – Darshan Pania Sep 24 '18 at 11:36