我在我的项目中使用flutter_local_notifications: 4.0.1+2
。出现通知“我正在尝试在iOS上播放自定义声音”。我尝试按照以下步骤为iOS实现自定义声音,但不起作用:
flutterLocalNotificationsPlugin
.resolvePlatformSpecificImplementation<
IOSFlutterLocalNotificationsPlugin>()
?.requestPermissions(
alert: true,
badge: true,
sound: true,
);
var initializationSettings = InitializationSettings(
android: initializationSettingsAndroid, iOS: initializationSettingsIOS);
flutterLocalNotificationsPlugin.initialize(initializationSettings);
const AndroidNotificationDetails androidPlatformChannelSpecifics =
AndroidNotificationDetails(
'Adhan Times Notification', 'Islamic App', 'Allah O Akbar',
priority: Priority.high,
sound: RawResourceAndroidNotificationSound('azan'));
const IOSNotificationDetails iOSPlatformChannelSpecifics =
IOSNotificationDetails(sound: 'azan.aiff');
azaan.aiff
文件位于app/ios/Runner
中。
任何帮助都将不胜感激谢谢
3条答案
按热度按时间mwngjboj1#
除了
IOSNotificationDetails
构造函数的sound
属性之外,playsound
属性必须设置为true。sg2wtvxw2#
也拖放声音文件在ios文件夹中的xcode
axr492tv3#
您可以在主屏幕的init方法中调用下面的方法