![](/img/trans.png)
[英]Custom iOS notifications sound local notifications package Flutter
[英]Flutter local notifications, custom sound not working for iOS
我在我的項目中使用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
中。
任何幫助,將不勝感激。 謝謝
除了IOSNotificationDetails
構造函數的sound
屬性外, playsound
屬性必須設置為 true。
您可以在主屏幕的 init 方法中調用以下方法
void _requestPermissions() {
flutterLocalNotificationsPlugin
.resolvePlatformSpecificImplementation<
IOSFlutterLocalNotificationsPlugin>()
?.requestPermissions(
alert: true,
badge: true,
sound: true,
);
flutterLocalNotificationsPlugin
.resolvePlatformSpecificImplementation<
MacOSFlutterLocalNotificationsPlugin>()
?.requestPermissions(
alert: true,
badge: true,
sound: true,
);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.