setDefaultRingtone static method

Future<void> setDefaultRingtone(
  1. String? ringtone
)

Sets the ringtone used for incoming calls that do not name one themselves, including calls raised from a data-only FCM payload while the app is dead.

Accepted values for ringtone (and for the per-call "ringtone" key of showCallNotification, and the "ringtone" field of an FCM payload):

  • null, '' or 'default' — the system ringtone.
  • a Flutter asset path, e.g. 'assets/sounds/incoming_call.mp3'. It must be listed under flutter: assets: in the host app's pubspec.yaml.
  • an Android raw resource, e.g. 'raw/incoming_call' or 'incoming_call' for android/app/src/main/res/raw/incoming_call.mp3.
  • a content://, android.resource://, file:// or http(s):// uri.
  • an absolute file path, e.g. '/storage/emulated/0/tone.mp3'.

Anything that cannot be resolved falls back to the system ringtone, so a bad value can never leave an incoming call silent.

Implementation

static Future<void> setDefaultRingtone(String? ringtone) async {
  try {
    await _channel.invokeMethod('setDefaultRingtone', {'ringtone': ringtone});
  } on PlatformException catch (e) {
    debugPrint("Error invoking setDefaultRingtone: ${e.message}");
  } on MissingPluginException {
    // Non-Android platform — nothing to configure.
  }
}