I am working on a Flutter application where I am utilizing the awesome-notifications
package to handle notifications. I want to implement a feature where a background sound and vibration play continuously until the user interacts with the notification.
I have explored the Awesome Notification documentation, but I couldn't find a direct solution for achieving this behavior. Has anyone successfully implemented continuous background sound and vibration until a notification is touched using the awesome-notifications
package in Flutter?
Any guidance, code snippets, or suggestions would be greatly appreciated.
Additional Information:
Flutter Version: 3.16 Awesome Notification Package Version: 0.8.2
@pragma('vm:entry-point')
Future<void> initializeNotification() async {
const int insistentFlag = 4;
final Int64List vibrationPattern = Int64List(4);
vibrationPattern[0] = 0;
vibrationPattern[1] = 4000;
vibrationPattern[2] = 4000;
vibrationPattern[3] = 4000;
await AwesomeNotifications().initialize(
null,
[
NotificationChannel(
channelKey: 'society',
channelName: 'My Channel Name',
channelDescription: 'Notification Example',
importance: NotificationImportance.Max,
channelShowBadge: true,
defaultColor: const Color(0XFF9050DD),
ledColor: Colors.white,
playSound: true,
defaultRingtoneType: DefaultRingtoneType.Alarm,
// criticalAlerts: true,
vibrationPattern: Int64List.fromList(<int>[insistentFlag]),
// enableLights: true,
enableVibration: true,
),
],
);
}
AwesomeNotifications().createNotification(
content: NotificationContent(
id: id,
channelKey: 'society',
title: payload['title'],
body: payload['body']!,
payload: payload,
autoDismissible: false,
wakeUpScreen: true,
category: NotificationCategory.Call),
actionButtons: [
NotificationActionButton(label: 'Label1', key: 'key1'),
NotificationActionButton(label: 'Label2', key: 'key2'),
]);
Works Fine on foreground but for background notifications it vibrates only once and sound is also short