Question #143EasyNative Integration

What is custom tone duration limitation for android and IOS , what will happen custom tone files duration is longer then tone what we have provided?

#android#ios

Answer

Overview

Both Android and iOS have strict limitations on custom notification ringtone file durations. If your custom tone file exceeds these limits, the OS falls back to the default system notification sound.


iOS Custom Tone Limitations

PropertyLimit
Max duration30 seconds
Supported formats
text
.aiff
,
text
.wav
,
text
.caf
File must beBundled in the app (not downloaded at runtime)
LocationMust be in the app's main bundle
dart
// Flutter Local Notifications — iOS custom sound
NotificationDetails(
  iOS: DarwinNotificationDetails(
    sound: 'custom_tone.aiff', // Must be ≤ 30 seconds, in main bundle
  ),
)

iOS Behavior if duration > 30s: The OS silently ignores the custom tone and plays the default system alert sound instead.


Android Custom Tone Limitations

PropertyDetails
Max durationNo strict OS limit — but practical limit is a few seconds
Supported formats
text
.mp3
,
text
.ogg
,
text
.wav
Location
text
res/raw/
folder in Android project
Notification ChannelSound is set per channel — cannot change per notification after channel creation
kotlin
// Android — set custom sound on notification channel
val sound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)
val channel = NotificationChannel(
    "my_channel",
    "My Channel",
    NotificationManager.IMPORTANCE_HIGH
).apply {
    setSound(
        Uri.parse("android.resource://$packageName/raw/custom_tone"),
        AudioAttributes.Builder()
            .setUsage(AudioAttributes.USAGE_NOTIFICATION)
            .build()
    )
}

Flutter Implementation

dart
// flutter_local_notifications package
const AndroidNotificationDetails androidDetails = AndroidNotificationDetails(
  'channel_id',
  'Channel Name',
  sound: RawResourceAndroidNotificationSound('custom_tone'), // no extension
  importance: Importance.high,
  priority: Priority.high,
);

const DarwinNotificationDetails iosDetails = DarwinNotificationDetails(
  sound: 'custom_tone.aiff', // ≤ 30 seconds
);

const NotificationDetails notificationDetails = NotificationDetails(
  android: androidDetails,
  iOS: iosDetails,
);

What Happens If Duration Exceeds Limit?

PlatformBehavior When Tone Too Long
iOSFalls back to default system sound silently
AndroidMay cut off the tone or loop — inconsistent behavior

Best Practices

  • ✅ Keep custom tones under 30 seconds (target 2–5 seconds for notifications)
  • ✅ Convert iOS sounds to
    text
    .caf
    format for better quality and compatibility
  • ✅ Test on actual devices — emulators may behave differently
  • ✅ For Android, set the sound at channel creation time — it cannot be changed once the channel exists
  • ❌ Do not use long music files as notification sounds