showImageNotification method
Future<int>
showImageNotification({
- required String title,
- required String message,
- required String imageUrl,
- String? channelId,
- NotificationImportance? importance,
- bool? autoCancel,
- String? targetScreen,
- Map<
String, dynamic> ? extraData,
override
Show a notification with an image.
Implementation
@override
Future<int> showImageNotification({
required String title,
required String message,
required String imageUrl,
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') {
final options = web.NotificationOptions(
body: message,
icon: imageUrl,
// Add more options as needed
);
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
}
}