相关疑难解决方法(0)

Flutter本地通知自定义声音不起作用(路径问题)


我想在 Android 端为本地通知设置自定义声音。我在Android项目的res文件夹中创建了一个raw文件夹。这是我将alarm.mp3 文件路径放入通知中的代码部分。
var androidPlatformChannelSpecifics =
                    new AndroidNotificationDetails(
                        "$id",
                        not.columnValue + not.deveui,
                        not.columnValue + not.deveui,
                        sound: "@raw/alarm",
                        importance: Importance.Max,
                        priority: Priority.High);
Run Code Online (Sandbox Code Playgroud)

其实还是用默认的系统声音。

如果我输入@raw/alarm.mp3,我会得到以下异常:Unhandled Exception: PlatformException(INVALID_SOUND, The resource %s could not be found. Please make sure it has been added as a raw resource to your Android head project., null)

注意:声音:RawResourceAndroidNotificationSound('alarm'),已解决

notifications flutter

12
推荐指数
1
解决办法
1万
查看次数

标签 统计

flutter ×1

notifications ×1