Firebase FCM真机推送无声音且提示Missing Default Notification Channel问题
问题排查及解决方案
问题根因说明
你遇到的两个问题核心诱因有两个:
- 通知通道ID不匹配,这是
Missing Default Channel告警的直接原因,也是通知无铃声的核心原因:你在AndroidManifest.xml和string.xml中配置的默认通知通道ID为fcm_default_channel,但Flutter侧创建通知时用的通道ID是default_notification_channel_id,二者完全不一致。原生Android系统对未匹配的通道会降级走系统默认配置,所以Pixel模拟器可以正常运行,但MIUI等定制ROM会直接拦截未知通道的通知铃音,甚至抛出通道缺失告警。 - Pocophone F1是小米旗下机型,MIUI对通知权限、省电策略有额外的定制限制,即使代码配置正确也可能被系统拦截铃音。
具体修复方案
1. 统一通知通道ID
将Flutter侧创建通知的通道ID替换为和string.xml一致的fcm_default_channel:
const AndroidNotificationDetails androidDetails = AndroidNotificationDetails( 'fcm_default_channel', // 此处替换为和配置文件一致的通道ID 'Notification', 'All Notification is Here', importance: Importance.max, priority: Priority.high, ticker: 'ticker', icon: "logo_rs", sound: RawResourceAndroidNotificationSound('betelgeuse'), playSound: true, );
修改后Missing Default Channel告警会直接消失。
2. 调整Node.js推送负载
安卓8.0及以上版本的通知铃音由通道配置控制,推送时指定通道ID可确保走你配置的自定义铃音:
var payload = { notification: { title : 'Antrian ' + data.dokter, body : "Pasien : " + pasien.id + '\nAntrian Anda Kurang : ' + counter + "\nAntrian Sekarang : " + noAntrian, android_channel_id: "fcm_default_channel", // 新增指定通道ID参数 sound : "betelgeuse.ogg" } };
3. 检查自定义铃音配置
确认你的betelgeuse.ogg文件存放在android/app/src/main/res/raw/目录下,文件名全小写、无特殊字符和空格,没有raw目录就手动创建。
4. 小米机型适配
- 应用启动时主动申请通知权限:
FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin = FlutterLocalNotificationsPlugin(); await flutterLocalNotificationsPlugin .resolvePlatformSpecificImplementation<AndroidFlutterLocalNotificationsPlugin>() ?.requestNotificationsPermission();
- 手动打开应用通知设置,确认
Notification通道的铃音、横幅权限都已开启,关闭MIUI省电模式/神隐模式对该应用的限制。
5. 生效验证
所有配置修改后必须卸载原有应用重装,因为安卓系统的通知通道一旦创建就无法修改,只有卸载重装才能让新的通道配置生效。
内容的提问来源于stack exchange,提问作者Ananda Pramono
相关产品推荐
相关产品推荐

