Android 9+ Notification sounds turned off by default

Hey there,
Recently we found out on our Android application that after fresh application installations the notification sounds are turned off by default, even though we defined clearly custom notification channels as well as a default one. All of the channels are of importance MAX and after application installation are registered properly in application notification settings. After manually turning the sounds on, notifications are coming as expected.
We are using now the latest version of Android SDK 3.4.0 with fcm (you could update the documentation of how to override the default FirebaseNotificationService).
Could you give us some guidance on how to configure it properly? Are we maybe missing some Android required permissions?

Hi Michał,

Can you show me the code you’re using to setup the notification channels?
By default without no configuration whatsoever, notifications are noisy and the OS uses the chosen default notification sound.

Here is an example configuration that makes noisy notifications:

        // Here we declare a new channel
        // On Android O this would create it once and leave it unchanged (except for name and description)
        // On Android pre O, this would reset the user preferences stored in WonderPush
        WonderPushUserPreferences.putChannel(
                new WonderPushChannel("important", null)
                        .setName("Important")
                        .setDescription("Important notifications you should not overlook.")
                        .setImportance(NotificationManagerCompat.IMPORTANCE_MAX)
                        .setColor(Color.RED)
                        .setLights(true)
                        .setLightColor(Color.RED)
                        .setSound(true)
                        .setSoundUri(new Uri.Builder()
                                .scheme(ContentResolver.SCHEME_ANDROID_RESOURCE)
                                .authority(getPackageName())
                                .path(String.valueOf(R.raw.sound))
                                .build())
                        .setVibrate(true)
                        .setVibrateInSilentMode(true)
                        .setVibrationPattern(new long[]{200, 50, 200, 50, 200})
        );

Even this makes noisy notifications:

            WonderPushUserPreferences.setDefaultChannelId("default");
            // The wrapping if serves to not modify existing preferences (as we don't store them elsewhere)
            // Note: We mainly create the channel to ensure its existence for the PreferenceActivity
            WonderPushUserPreferences.putChannel(
                    new WonderPushChannel("default", null)
                            .setName("Default")
                            .setDescription("Miscellaneous notifications.")
            );
        }

I’ve updated the documentation about the WonderPushFirebaseNotificationService renaming.

Best,

Hi there, here is the code:

private fun createPushNotificationChannel(channel: ApplicationNotificationChannel) {
    val soundUri = Uri.Builder()
            .scheme(ContentResolver.SCHEME_ANDROID_RESOURCE)
            .authority(applicationPackage.name)
            .path(channel.soundRawRes.toString())
            .build()
    val wonderPushChannel: WonderPushChannel = WonderPushChannel(channel.id, null)
            .setName(channel.channelName)
            .setImportance(NotificationManagerCompat.IMPORTANCE_MAX)
            .setLights(true)
            .setSound(true)
            .setSoundUri(soundUri)
            .setVibrate(true)
            .setVibrateInSilentMode(true)

    WonderPushUserPreferences.putChannel(wonderPushChannel)
}

private fun createNotificationChannels() {
        ApplicationNotificationChannel.values().forEach(::createPushNotificationChannel)
        WonderPushUserPreferences.setDefaultChannelId(ApplicationNotificationChannel.DEFAULT.id)
    }

Channels are created during WonderPush initialisation. Thanks for updating the documentation. I will test it once again with the FCM updated.

Edit:
After testing the notifications are still soundlees on Android 9+ (api 28+) devices, we need to manually turn on the notification sounds. Maybe there is something wrong with channel configuration?