Search code examples
push-notificationcodenameone

Push notification sound with CodeNameOne


I'm trying to play the default system sound when a phone receives a push notification.

Here is the query I use:

String query = "token="+ "token" +
                        "&device="+ session.getPushKey()+
                        "&type="+ notification.getType() +
                        "&auth="+ "auth" +
                        "&certPassword="+ "certPass"+
                        "&cert="+ "cert"+
                        "&body="+ notification.getBody() +
                        "&production="+ "true"+
                        "&sound=default";

My phone (A Samsung S20) receives the push notification but no sound and no vibration. The app isn't muted, same for the phone. I've tried with friends phone but the result is the same.

Am I missing something ?

Btw, is there a way to play a custom sound ? I found while searching online that a .wav file works and needs to be put here "/android/raw/bellbox.wav". But as phones don't play sound and vibration, I can't be sure of that. Is it the right path ?

Thanks


Solution

  • Make sure you have the following build hints in the application:

    android.NotificationChannel.importance=4
    android.newFirebaseMessaging=true
    

    Notice that if you include them in the settings directly they need to be prefixed with codename1.arg.. If this doesn't solve the problem please edit your question with the details of your android.* build hints and the Android version where this is failing.