showNotificationWithActions method
Future<int>
showNotificationWithActions({
- required String title,
- required String message,
- required List<
Map< actions,String, String> > - String? channelId,
- NotificationImportance? importance,
- bool? autoCancel,
- String? targetScreen,
- Map<
String, dynamic> ? extraData,
override
Show a notification with custom actions.
Implementation
@override
Future<int> showNotificationWithActions({
required String title,
required String message,
required List<Map<String, String>> actions,
String? channelId,
NotificationImportance? importance,
bool? autoCancel,
String? targetScreen,
Map<String, dynamic>? extraData,
}) async {
try {
// Check if the browser supports notifications
if (!_isNotificationSupported()) {
return -1;
}
if (web.Notification.permission == 'granted') {
// Convert actions to NotificationAction objects if supported
final options = web.NotificationOptions(
body: message,
// Note: actions are part of Service Worker notifications
// For basic notifications, we'll just show the message
);
final notification = web.Notification(title, options);
return 1; // Return a notification ID
}
return -1; // Failed to show notification
} catch (e) {
return -1; // Failed to show notification
}
}