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.
Restore default: pass 0 - setNotificationSound(0)
3.2 Alternative - Uri#
Use a content:// or android.resource:// Uri when the sound is provided dynamically.
Restore default: pass null - setNotificationSoundUri(null)
| Constraint | Detail |
|---|---|
file:// URIs | Not supported (Android 7+). Ignored; SDK falls back to default sound. |
content:// URIs | Must be readable by the system UI. If using FileProvider, grant read access to "com.android.systemui". |
| Timing | Must be called BEFORE Initialize() / createDiyalog(). |
4. Integration Steps#
- Add your sound file to the host app:
app/src/main/res/raw/my_notification_sound.ogg(or.wav/.mp3). - In
Application.onCreate()(or your existing Diyalog setup), configure the engine before initialization. - Call
setNotificationSound(...)orsetNotificationSoundUri(...). - Then call
Initialize()/createDiyalog()as you already do today. - Build, install, and verify with a real incoming message while the app is in the background.
4.1 Sample code (Application)#
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.diyalogappchannel and default sound remain unchanged
6. Verification Checklist#
- Sound resource exists under
res/rawand compiles asR.raw.* -
setNotificationSound/setNotificationSoundUriis called beforeInitialize() - 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#
| Symptom | Likely cause / action |
|---|---|
| Still hearing default sound | Call was made after Initialize(), or setNotificationSound(0)/null was used. Move the call before init and reinstall / reopen the app. |
| No sound at all | Check notification permission, channel importance, and that messenger notification sound is enabled in SDK settings. |
| Uri sound ignored | file:// 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)