这是我的通知功能,如何从资产中设置自定义声音?
Future<void> _repeatNotification() async {
var androidPlatformChannelSpecifics = AndroidNotificationDetails(
'repeating channel id',
'repeating channel name',
'repeating description',
);
var iOSPlatformChannelSpecifics = IOSNotificationDetails();
var platformChannelSpecifics = NotificationDetails(
androidPlatformChannelSpecifics, iOSPlatformChannelSpecifics);
await flutterLocalNotificationsPlugin.periodicallyShow(0, 'Title',
'Body', RepeatInterval.EveryMinute, platformChannelSpecifics);
}
应从本机Android和iOS项目设置自定义声音。对于Android,这将是raw
文件夹。
您可以在实例化NotificationDetails的同时定义其名称来播放自定义声音
AndroidNotificationDetails(
'repeating channel id',
'repeating channel name',
'repeating description',
sound: 'your_sound_file_name',
);
IOSNotificationDetails(sound: "your_sound_file_name.aiff")
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句