Skip to main content

Custom Notification Sound

Host Application Integration Guide

Diyalog Android SDK - Message & In-App Notification Sound Configuration

Document version: 1.0 | Audience: Host app Android developers

1. Overview#

The Diyalog Android SDK allows the host application to provide its own notification sound for SDK message notifications. When configured, this sound is used for:

  • System message notifications (background / killed app)
  • In-app message sounds (app in foreground)
  • Inactive-user notifications

If the host does not configure a sound, behavior is unchanged: the SDK continues to use the existing notification channel and the system default sound. Call ringtone / ringing sound is not affected.

2. Prerequisites#

  • Diyalog Android SDK with host notification-sound support
  • A short audio file suitable for notifications (recommended: .ogg, .wav, or .mp3)
  • Place the file under your host app module: res/raw/ (example: res/raw/my_notification_sound.ogg)

3. API Reference#

3.1 Recommended - raw resource#

Use this when the sound ships inside the host APK/AAB.

DiyalogEngine.diyalogInstance()
.setNotificationSound(R.raw.my_notification_sound);

Restore default: pass 0 - setNotificationSound(0)

3.2 Alternative - Uri#

Use a content:// or android.resource:// Uri when the sound is provided dynamically.

Uri soundUri = Uri.parse(
"android.resource://" + getPackageName() + "/" + R.raw.my_notification_sound);
DiyalogEngine.diyalogInstance().setNotificationSoundUri(soundUri);

Restore default: pass null - setNotificationSoundUri(null)

ConstraintDetail
file:// URIsNot supported (Android 7+). Ignored; SDK falls back to default sound.
content:// URIsMust be readable by the system UI. If using FileProvider, grant read access to "com.android.systemui".
TimingMust be called BEFORE Initialize() / createDiyalog().

4. Integration Steps#

  1. Add your sound file to the host app: app/src/main/res/raw/my_notification_sound.ogg (or .wav / .mp3).
  2. In Application.onCreate() (or your existing Diyalog setup), configure the engine before initialization.
  3. Call setNotificationSound(...) or setNotificationSoundUri(...).
  4. Then call Initialize() / createDiyalog() as you already do today.
  5. Build, install, and verify with a real incoming message while the app is in the background.

4.1 Sample code (Application)#

@Override
public void onCreate() {
super.onCreate();
DiyalogEngine engine = DiyalogEngine.diyalogInstance();
// ... your existing host configuration ...
// MUST be before Initialize() / createDiyalog()
engine.setNotificationSound(R.raw.my_notification_sound);
// Existing initialization
engine.createDiyalog(this);
}

5. Android 8+ (Oreo) Channel Behavior#

Android does not allow changing a notification channel's sound after the channel is created. Therefore:

  • When a host sound is set, the SDK uses a dedicated channel: im.diyalog.diyalogapp.sound.<hash>
  • The previous SDK message channel is removed so the new sound can take effect
  • Any user-customized settings on the old channel are reset
  • If nothing is configured by the host, the existing im.diyalog.diyalogapp channel and default sound remain unchanged

6. Verification Checklist#

  • Sound resource exists under res/raw and compiles as R.raw.*
  • setNotificationSound / setNotificationSoundUri is called before Initialize()
  • App notification permission is granted (Android 13+)
  • Device volume / Do Not Disturb allows notification sounds
  • Receive a message with the app in background and confirm the custom sound plays
  • Optional: receive a message in foreground and confirm in-app sound uses the same host sound
  • Confirm call ringtone is unchanged

7. Troubleshooting#

SymptomLikely cause / action
Still hearing default soundCall was made after Initialize(), or setNotificationSound(0)/null was used. Move the call before init and reinstall / reopen the app.
No sound at allCheck notification permission, channel importance, and that messenger notification sound is enabled in SDK settings.
Uri sound ignoredfile:// is rejected. Use android.resource:// or a readable content:// Uri.
Sound change not applied on Android 8+Expected: channel sound is immutable. SDK creates a new channel for the new sound. Trigger a fresh notification after the change.

For support, contact your Diyalog integration representative and include SDK version, device OS version, and whether the call was made before Initialize().

Diyalog - Host Integration Guide (Custom Notification Sound)