在android项目中添加raw文件夹:
android>app>src>main>res> 新建 Android 资源目录 > 选择 Raw > 在此处添加您的声音
Result Folder :
- android
- app
- src
- main
- res
- raw
lawgo_sound_notification.mp3
实施您的本地通知代码:
var androidPlatformChannel = new AndroidNotificationDetails(
"your_channel_id", "name", "desc_channel",
sound: RawResourceAndroidNotificationSound('lawgo_sound_notification'),
playSound: true,
importance: Importance.Max,
priority: Priority.High);
添加 onResume、OnLaunch 支持,当应用程序在后台运行时,通知负载应设置为:
{ "notification" : {
"body" : "Body of Your Notification",
"title": "Title of Your Notification",
"android_channel_id": "your_channel_id"
},
"data" : {
"body" : "Body of Your Notification in Data",
"title": "Title of Your Notification in Title",
"click_action": "FLUTTER_NOTIFICATION_CLICK",
}
}
**important should add "android_channel_id": "default_notification_channel_id"**