Flutter 默认提供 PWA 服务来将网站安装为 Light 应用程序。
我想将我的网站安装为应用程序。为此,它需要一个 http 服务器,因此我将其上传到 github 上。在 github 上上传后,我得到了我的网站的 url。在 chrome 中打开该网站
1. 网站加载时间过长。
2.我在控制台中收到错误无法从服务工作人员加载应用程序。回到普通的 <script> 标签。
我还创建了一个新项目并上传到 github 上以进行 http 服务器访问。在新项目中我遇到了相同的错误并需要时间来加载。
请建议我缺少什么或 PWA 需要任何额外配置。
当应用程序终止/从后台删除最近的应用程序时,我面临收到通知的问题。
我已经在应用程序或项目级别的 build.gradle 文件中完成了 Android 应用程序所需的所有设置。当应用程序打开或应用程序位于最近的应用程序中时,我能够收到推送通知。
库版本
firebase_messaging: ^11.2.0
firebase_core: ^1.10.0
flutter_local_notifications: ^9.1.4
Run Code Online (Sandbox Code Playgroud)
这是我的代码。
await Firebase.initializeApp();
Run Code Online (Sandbox Code Playgroud)
FirebaseMessaging messaging = FirebaseMessaging.instance;
messaging.getToken().then((value) {
print('firebase token =$value');
});
FirebaseMessaging.onMessage.listen((RemoteMessage message) async {
//print(event.notification!.body);
RemoteNotification? notification = message.notification;
if (notification != null) {
print("Notification received when app in foreground");
}
});
FirebaseMessaging.onMessageOpenedApp.listen((message) {
print('Message clicked!');
});
await FirebaseMessaging.instance.setForegroundNotificationPresentationOptions(
alert: true,
badge: true,
sound: true,
);
Run Code Online (Sandbox Code Playgroud)
背景消息处理程序代码如下
Future<void> _messageHandler(RemoteMessage message) async {
await Firebase.initializeApp();
RemoteNotification? notification = message.notification;
if (notification != null) {
print("Notification …Run Code Online (Sandbox Code Playgroud) android push-notification firebase flutter firebase-cloud-messaging
当用户SIGN-IN METHOD在 android 中使用 Firebase 电子邮件/密码注册时,我们如何验证他们的电子邮件?