I'm wondering if I can implement local notification in flutter web? I saw that I can create local notification for mobile app Android or IOS but is it possible to use it for web app? or any other alternative to accomplish it?
Just use the class Notification in dart:html package. You can do something like this:
import 'dart:html' as web;
Future<void> showNotification( String message ) async {
var permission = web.Notification.permission;
if (permission != 'granted') {
permission = await web.Notification.requestPermission();
}
if (permission == 'granted') {
web.Notification( message );
}
}
More info about the javascript notification API here: https://developer.mozilla.org/en-US/docs/Web/API/Notifications_API/Using_the_Notifications_API
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With