Closed iSaqibShafique closed 3 days ago
Attention, also when I give custom sounds, it plays on earpiece not on speaker in iOS.
Could you solve the problem? I have the same problem.
For all the issues you're reporting, I don't see how any of them are to do with the plugin especially when you already say the default sound is slow. Furthermore, you mention sounds playing on earpiece not on the speaker. All of these device related and the native APIs don't provide any capability on where the audio should play let alone the plugin.
As for custom sound not working, this would be an issue in your app to resolve in making you set things up properly. This would be for you to resolve and the example app shows that this is working.
Could you solve the problem? I have the same problem.
Yes I did by changing the getting permission method to this.
if (Platform.isAndroid) { await Permission.notification.isDenied.then((value) { if (value) { Permission.notification.request(); } }); } else { await flutterLocalNotificationsPlugin .resolvePlatformSpecificImplementation< IOSFlutterLocalNotificationsPlugin>() ?.requestPermissions( alert: true, badge: true, sound: true, critical: true, provisional: true, ); }
Sounds like you identified the cause so closing this
Describe the bug I was using custom audios in Android and for iOS, Android is working good, but in iOS these are the problems. 1 - Notification sound too slow when notify. 2 - When using custom sound Notifications not working in iOS.
To Reproduce
Expected behavior
Sample code to reproduce the problem static Future init() async {
const AndroidInitializationSettings initializationSettingsAndroid =
AndroidInitializationSettings('logo');
final DarwinInitializationSettings initializationSettingsDarwin =
DarwinInitializationSettings(
onDidReceiveLocalNotification: (id, title, body, payload) =>
Get.toNamed(AppRoutes.home, arguments: 3),
requestSoundPermission: true,
requestAlertPermission: true,
);
const LinuxInitializationSettings initializationSettingsLinux =
LinuxInitializationSettings(defaultActionName: 'Open notification');
final InitializationSettings initializationSettings =
InitializationSettings(
android: initializationSettingsAndroid,
iOS: initializationSettingsDarwin,
linux: initializationSettingsLinux,
);
}
static Future showScheduleNotifications({
required DateTime notificationTime,
required String bodyText,
String? audio,
}) async {
try {
int notificationId = notificationTime.millisecondsSinceEpoch ~/ 1000;
AndroidNotificationDetails androidNotificationDetails =
AndroidNotificationDetails(
notificationId.toString(),
notificationId.toString(),
channelDescription: notificationId.toString(),
importance: Importance.max,
priority: Priority.high,
ticker: 'ticker',
sound: RawResourceAndroidNotificationSound(audio),
enableVibration: true,
);
NotificationDetails notificationDetails = NotificationDetails(
android: androidNotificationDetails,
iOS: const DarwinNotificationDetails(),
);
}