Gan*_*mar 7 web-notifications flutter-web flutter-local-notification
我想知道是否可以在 flutter web 中实现本地通知?我看到我可以为 Android 或 IOS 移动应用程序创建本地通知,但是否可以将其用于网络应用程序?或任何其他替代方案来实现它?
Notification只需使用包中的类即可dart:html。你可以这样做:
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 );
}
}
Run Code Online (Sandbox Code Playgroud)
有关 javascript 通知 API 的更多信息,请访问:https://developer.mozilla.org/en-US/docs/Web/API/Notifications_API/Using_the_Notifications_API
| 归档时间: |
|
| 查看次数: |
995 次 |
| 最近记录: |