0

I have an issue with the custom sound of PubNub notification android Os,the sound is always the default sound, I try like this:

if(Platform.OS=='android'){
           
         let channel=`notif1`
        pubnub.publish({message:{"pn_gcm" : {
         "notification": {
             "title":"hello",
             "body":"body message",
             "sound":"beep.wav"
         },
         "data" :objectToPost
        }
        },
       channel:channel})
     }

please help me to change the sound from the file in \android\app\src\main\res\raw

Prajwal Kulkarni
  • 1,177
  • 8
  • 20
  • Can you provide a more complete code sample? Even the JSON payload you provided is not complete. Thanks. – Craig Conover Nov 13 '21 at 14:59
  • Maybe the sound file doesn't exist in the app? [Android/FCM docs say this](https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#androidnotification): "The sound to play when the device receives the notification. Supports "default" or the filename of a sound resource bundled in the app. Sound files must reside in /res/raw/. – Craig Conover Nov 13 '21 at 15:14
  • This guy seems to have had the same issue a year ago: https://github.com/evollu/react-native-fcm/issues/565#issuecomment-631540373 – Craig Conover Nov 13 '21 at 15:24
  • review this SO post as it might have something that might help you https://stackoverflow.com/questions/50567164/custom-notification-sound-not-working-in-android-oreo – Craig Conover Nov 13 '21 at 15:25
  • Back to my origin comment - send full code snippet but I think there is something more subtle at play here and not PubNub related. Most likely your Android app's config/impl is the root cause. PubNub just passes the payload onto FCM and FCM delivers it to the device and even then, it's not in PubNub's control to handle/process/display the notification. – Craig Conover Nov 13 '21 at 15:27
  • I add the the payload as json ,i waiti yours reply and thinks – Nejib Afdhal Nov 15 '21 at 08:46
  • pretty sure whatever sound you want to have made, that sound file needs to be in our app on the client device. have you done that? Also, consult Android docs for how to do this. – Craig Conover Nov 15 '21 at 23:37

0 Answers0